tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: quick question about redirects
Date Mon, 20 Mar 2000 08:19:11 GMT
Bryan Murphy wrote:
> How does HtmlServletResponse.sendRedirect() work under Jakarta 3.1?
> I just moved my app over from JServ to Jakarta and so far everything
> appears to be running great, except for the sendRedirect() functions.
> I was under the impression that sendRedirect() happened immediately and
> halted the execution of the servlet.  However, this isn't what happens
> with Jakarta.  I'm not sure if it was some code change I made when I
> moved it over to Jakarta, or if Jakarata behaves differently than JServ
> did.
> What is the correct behaviour of sendRedirect that I should expect?

sendRedirect() should set the Location header and the status code,
and write a standard body to the response. Two things to be aware of:
1) You must not write any more stuff to the body after calling this
   method. Typically you would return from doGet/doPost() immediately
   after calling the method.
2) If you have already flushed the response buffer, explicitly by calling
   flush() or implicitly by writing more to the response than the buffer
   can hold, the response is "committed" and can't set headers and the status
   code so the redirect doesn't work.

Hans Bergsten
Gefion Software

View raw message