ashwin soorkeea a écrit :
Hello all,
I have a problem for my application and this prob is causing an entire netw=
ork of users from using my application. I will appreciate
if you guys can help me solve my prob.
It concerns the servlet response.sendRedirect(...) method. When using the response.sendRedirect("/myexample") in my java class, i do n=
ot want the servlet engine to reconstruct
an absolute URL, before sending the response to the browser. I want it to b=
e handle by the browser keeping it relative throughout
the application. I know it's possible, but i dunno how to do it. Can you he=
lp ?=20
If you use sendRedirect, it's not possible:


     sendRedirect

public void *sendRedirect*(java.lang.String location)
                 throws java.io.IOException

Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container _must convert the relative URL to an absolute URL before sending the response to the client_. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.
The URL reconstruction by the servlet engine during a redirection is causin=
g some problems in my application.
It shouldn't unless either application or tomcat has bugs. :)
Example:
I have this link on browser http://127.0.0.1:<port_number>, when performing=
 a sendRedirect, i'm losing the <port_number>
during the url reconstruction by the servlet engine.
That's probably because tomcat is not aware, for various reason, of the correct port number (behind a proxy or apache for example). You can specify in tomcat configuration which port number to use when reconstructing urls: http://tomcat.apache.org/tomcat-4.1-doc/config/http11.html (see 'redirectPort')

On the other hand, i have another application that is interconnected, but i=
n this application, the url is relative throughout, even though
it passes through the response.sendRedirect(...) and consequently, i do not=
 have this prob in this application.
If it's relative, it's not using sendRedirect , but it's setting by itself the response header (response.addHeader() )
Im using tomcat-4.1 and i'm checking the URL redirection using the HTTP liv=
e header plugins for firefox.
Maybe try to upgrade? ;)


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to