File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes redirecting the request to URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "redirecting the request to URL" Watch "redirecting the request to URL" New topic
Author

redirecting the request to URL

Shakti Sharma
Ranch Hand

Joined: Dec 19, 2000
Posts: 60
I want to redirect the request to url in different application through https. Problem is I cannot use request.sendRedirect because contents of the original request, such as POST parameters, will be lost. Is there any alternative.
Thanks
Gaurav Jain
Ranch Hand

Joined: Mar 11, 2004
Posts: 108
use the requestdispatcher.forward() method.
Shakti Sharma
Ranch Hand

Joined: Dec 19, 2000
Posts: 60
requestdispatcher.forward() method only works when you are forwarding the request in same application. In my case I am trying to forward request to another application.
Shakti Sharma
Ranch Hand

Joined: Dec 19, 2000
Posts: 60
Originally posted by Gaurav Jain:
use the requestdispatcher.forward() method.
danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
Use URL rewriting
Brahim Bakayoko
Ranch Hand

Joined: Aug 29, 2003
Posts: 155
Originally posted by danny liu:
Use URL rewriting

URL rewriting is for session management.
Use a HttpClient to make a new post request.


SCJP, SCWCD, SCBCD, IBM CSD WebSphere v5, <br />A+, MCP 2000 and 2000 server, CST, and few incompleted certification tracks.<br /> <br />Ivory Coast<br /> <br />Analyze your web Request/Response @ <a href="http://webtools.servehttp.com" target="_blank" rel="nofollow">http://webtools.servehttp.com</a> down for a while...
Shakti Sharma
Ranch Hand

Joined: Dec 19, 2000
Posts: 60
Hi Brahim,
Can you explain what is HTTPClient and how to use it.
Thanks
Shak
Brahim Bakayoko
Ranch Hand

Joined: Aug 29, 2003
Posts: 155
Originally posted by Shakti Sharma:
Hi Brahim,
Can you explain what is HTTPClient and how to use it.
Thanks
Shak


http://jakarta.apache.org/commons/httpclient/
You can also use an URLConnection object.
Nitin Mehhta
Ranch Hand

Joined: May 18, 2004
Posts: 48
requestdispatcher.forward() can be used to call requests from a different application also. For that you need to have the servlet context of that aaplication. I do not have the exact code with me, but i know that it can be done. Would try to post the exact code when i get hold of it.
Hemanth Presingu
Ranch Hand

Joined: Oct 01, 2000
Posts: 30
You can write a java httpclient to forward the request to another servlet in a different JVM.

URL url = new URL("http://www.xyz.com/anotherservlet");
URLConnection urlConn = url.openConnection();
urlConn.setUseCaches(false);
ObjectInputStream in = new ObjectInputStream(urlConn.getInputStream());
in.close();

-Hemanth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: redirecting the request to URL
 
Similar Threads
Using a servlet to initiate a request
generating numbers from 1 to 100 to store in an array
JSP swing communication
redirect ?
core java communicates with servlet or jsp?