You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kitching Simon <Si...@orange.ch> on 2000/08/26 13:09:25 UTC

RE: sendRedirect ??

Hi ,

> -----Original Message-----
> From:	Mahesh Koli [SMTP:m_c_koli@hotmail.com]
> Sent:	Thursday, July 27, 2000 10:23 PM
> To:	tomcat-user@jakarta.apache.org
> Subject:	sendRedirect ??
> 
> Hello,
> >
> >   I am currently involved in two dotcom projects, which we are
> implementing
> > on Suse Linux 6.4 using Jakarta-Tomcat 3.1 as servlet and jsp engine .
> > Overall we are satisfied with the engine but there are few observations
> for
> > which we don't seem to find an answer
> > They are as follows
> >
> > 1.When we use response.sendRedirect we sometimes get an exception as
> > "Response has been already committed" .This error we get intermittently
> for
> > the same code .we have not been able to find the exact reason for the
> error
> >
> > We have also found some other inconsistent behaviours which we would
> like to
> > know .
> >
> > Can you help us in the same
> >
> > Thanks in advance,
> >
> > Mahesh Koli
> [Kitching Simon]  
As a jsp page (or servlet) runs, it writes data to an output buffer which
periodically
gets flushed down the network connection to a user's browser. The webserver/
jsp-engine does *not* wait for the entire page to be generated before
starting
to send (there are all sorts of buffering-control features in the servlet
spec if you look for them).

However, there are *some* operations which require that no output has yet
been sent to the user,
eg response.sendRedirect().

If you happen to put these sorts of method calls (or <jsp:xyz> tag that
generates such a call)
"too far down" your jsp page or servlet code, so that data has already been
flushed to the client, 
then the requested operation cannot be performed, and an exception is
thrown.

The solution is to make sure any such commands are evaluated *first* in your
code.

Hope this helps..



>