I am trying to understand the behavior of sendRedirect(). The Servlet
Spec states:
The sendRedirect method will set the appropriate headers and content
body to direct the
client to a different URL. It is legal to call this method with a
relative URL path, however the
underlying container must translate the relative path to a fully
qualified URL for transmission back
to the client. If a partial URL is given and, for whatever reason,
cannot be converted into a valid
URL, then this method must throw an IllegalArgumentException.
What I find somewhat ambiguous is the line "the underlying container
must translate the relative path to a fully qualified URL". Does this
the container should insert the context path in the URL? That is,
suppose I have an application whose root is /Test. In my code, I do the
following:
response.sendRedirect("/ReallyATest");
Should the address sent to the client be:
A) http://myserver/ReallyATest
B) http://myserver/Test/ReallyATest
It seems that Apache follows A. It does not insert the context path.
However, I am also using IBM WebSphere 3.5 and it does B! So, which is
the right one?
For now, I will use the following work around for portability:
response.sendRedirect(request.getRemoteHost() + request.getContextPath()
+ "ReallyATest");
Thanks,
Paolo
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]