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?
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.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
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).
Joined: Nov 12, 2004
Thanks for the reply, but how do I retrieve the URL contained in the HTTPResponse? Is the method losted in javadoc?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: How does a servlet know when it is being redirected to the right page