Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

redirecting the request to URL

 
Shakti Sharma
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the requestdispatcher.forward() method.
 
Shakti Sharma
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gaurav Jain:
use the requestdispatcher.forward() method.
 
danny liu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use URL rewriting
 
Brahim Bakayoko
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by danny liu:
Use URL rewriting

URL rewriting is for session management.
Use a HttpClient to make a new post request.
 
Shakti Sharma
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brahim,
Can you explain what is HTTPClient and how to use it.
Thanks
Shak
 
Brahim Bakayoko
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic