> I think this might have to do with both applications running of the
> same port on the server. How can I fix this?
As long as they have different contexts, you should be okay. The
mentioned exception occurs when you try to write to the response after
it has been committed. Can you provide more information around the two
applications? This should happen to an application regardless of it's
coexistance with another, as the contexts are totally different.
-cheers,
Manish
javadev - 14 Nov 2006 10:02 GMT
> As long as they have different contexts, you should be okay. The
> mentioned exception occurs when you try to write to the response after
> it has been committed. Can you provide more information around the two
> applications? This should happen to an application regardless of it's
> coexistance with another, as the contexts are totally different.
The 2 applications are deployed separately through the Tomcat Manager
which I assume should create separate contexts for them.
I get the same error message on NetBeans (which I use to develop the
applications) but my application runs fine through NetBeans. However
when I deploy the 2nd application and try to run it on the server, then
I can access the index.jsp which contains a login page. On submitting
this page, I get the stack trace of the above error.
> Servlet.service() for servlet jsp threw exception
> java.lang.IllegalStateException: getOutputStream() has already been
> called for this response
Uusually triggered by calling RequestDispatcher.forward() or some
ServletResponse methods (like setting response headers) that don't
like it if you have tried to get hold of the (body) output stream
(i.e. you have committed the response). Since it cannot know whether
you have written to it it just assumes you have been naughty and done
so.
> I think this might have to do with both applications running of the
> same port on the server. How can I fix this?
It doesn't have anything to do with the port: You can have as many
distinctly named web applications you like (for practical purposes) on
the same Tomcat.
adwords@pulpjava.com - 15 Nov 2006 22:44 GMT
There's a good change you've opened your PrintWriter, and then done a
forward. A forward expects a clean, virginal PrintWriter.
Check that you're not doing a Print before or after forwarding with the
RequestDispatcher.
Cheers!
-Cameron McKenzie
Author of the SCJA Certification Guide and What is WebSphere?
Free WebSphere Tutorials: www.pulpjava.com
Free Mock Java Certification Exams: www.scja.com
Free J2EE and Java Multimedia Tutorials: www.mcnz.com
Certification Resources: www.examscam.com
> > Servlet.service() for servlet jsp threw exception
> > java.lang.IllegalStateException: getOutputStream() has already been
[quoted text clipped - 13 lines]
> distinctly named web applications you like (for practical purposes) on
> the same Tomcat.
javadev - 16 Nov 2006 11:22 GMT
Hi Tor
It turned out that it was being caused by the RequestDispatcher's
forward() call. I've changed those now to jsp:forward and it works fine
now.
Thanks
Swetha
> There's a good change you've opened your PrintWriter, and then done a
> forward. A forward expects a clean, virginal PrintWriter.
[quoted text clipped - 30 lines]
> > distinctly named web applications you like (for practical purposes) on
> > the same Tomcat.