• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does a servlet know when it is being redirected to the right page

 
Vivian Ryder
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a servlet that will send certain parameters to a foreign servlet which will decide on which web page to display basing on the parameters sent. And my web application will process accordingly depending on which web page is sent. My problem is that how will my servlet know which web page it is being redirected. Is there any way I can know the URL of the web page that I am being redirected to?

Thank you

Vivian
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not ask in our Servlets forum? Here, I'll move this there for you.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is your servlet communicating with the foreign one ... URL or HttpURLConnection or something like that? Look in the doc or on Google for a "follow forward" option that makes one of those (forget which) automatically follow any forward headers sent back by the foreign servlet. I've set this to true before (maybe the default) but never really tested how well it works.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
redirect is a clientside action therefore the HTTP response will contain the redirect URL as well as a return code in the 300 range indicating you're being redirected.

If the request is forwarded otoh you will notice nothing and you shouldn't bother as forward is purely serverside and completely transparent to the client (all the client notices is that the actual data in the response are different for different requests).
 
Vivian Ryder
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, but how do I retrieve the URL contained in the HTTPResponse? Is the method losted in javadoc?

Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic