You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Bare <ch...@yahoo.com> on 2002/03/19 19:05:58 UTC

Re: response.sendRedirect not redirecting

--- Mostafa Al-Mallawani <mo...@aucegypt.edu> wrote:
> Hi,
> I have a problem with redirecting.  In my JSP page I
> keep checking for
> errors, whenever I catch one, I set a variable on
> the session object and
> then forward to an error page; this could happen up
> to 5 times in one
> page.  The weird thing is, redirection works on some
> pages and does
> absolutely nothing on some other pages.  Execution
> just passes over
> response.sendRedirect("../error.jsp"); like it
> doesn't even exist.
> Please help, this is really frustrating.  Thanks.
> 


I am guessing that this happens because you are
calling sendRedirect after writing something to the
response that causes it to be "committed". Once the
servlet container (tomcat) considers the response
committed it can start streaming it to the browser,
and so at that point it's kind-of too late to change
your mind and redirect. Attempting to redirect at this
point will cause an IllegalStateException. Maybe your
error catching code is eating this exception.

Look at the JavaDocs for the Servlet API, specifically
HttpServletResponse.sendRedirect() for a clearer
explaination.

Hope this helps,

-Chris




__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>