In a nutshell, once you forward you should ensure nothing else is sent to the
output. Similarly once you start outputing a page, don't change your mind and
forward.
Thus your code should look something like this:
if (errorMessage != null) {
response.sendRedirect (request.getContextPath() +
"/someotherpage.jsp") ;
return;
}
out.println ("<html>");
...
Not like this:
if (errorMessage != null) {
response.sendRedirect (request.getContextPath() +
"/someotherpage.jsp") ;
}
out.println ("<html>");
...
This is a common mistake.
I suspect that you are doing the reverse with the exception you are getting.
That is you are doing this:
out.println ("<html>");
...
if (somethingBadHasHappened) {
errorMessage = "Uh Oh, something bad has happened.";
}
...
if (errorMessage != null) {
response.sendRedirect (request.getContextPath() +
"/someotherpage.jsp") ;
}
As for documentation, there are a great many titles on Servlets at the local
book store. Also try searching the web there are plenty of tutorials and
samples out there.
I hope this helps
Glenn Mc
----- Original Message -----
From: "Deepa Paranjpe" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[email protected]>
Sent: Thursday, August 30, 2007 10:01 AM
Subject: Java servlets
> Hi all,
>
> This is not a question specific to tomcat but more about servlets.
> I am using a dispatcher forward to invoke another servlet.
> Why do I get an exception --> java.lang.IllegalStateException: Cannot forward
> after response has been committed
>
> For some reason I am unable to find good documentation to do complicated
> servlets invocations. Does any one know?
>
>
>
> Ole Ersoy <[EMAIL PROTECTED]> wrote:Incidentally - since we are talking about
> pooling - should the executor configuration be a tip? It allows the
> connectors to share a single thread pool, rather than each connector having
> its own. This seems like a memory and performance slurpee to me.
>
> Cheers,
> - Ole
>