This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

redirecting the request to URL

 
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
 
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.

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use URL rewriting
 
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.
 
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.
 
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
 
    Bookmark Topic Watch Topic
  • New Topic