tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lindsay.hamo...@bt.com
Subject RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem?
Date Fri, 08 Mar 2002 13:25:48 GMT
OK here's the sequence of events:

[ Note: all forwarding done using RequestDispatcher.forward(req,res) ]

1. User begins by clicking link to Login servlet
2. Login servlet forwards to login.jsp
3. Login.jsp submits request to Login servlet
4. Servlet authorizes user and forwards to Home servlet
5. Home servlet forwards to home.jsp
NO EXCEPTIONS YET - EVERYTHING IS OK!
6. User then chooses an action (e.g. create new agent, in my example) from
home.jsp and submits request to Home servlet
7. Home servlet processes request and forwards to appropriate servlet
(called Create in my example)
8. Create servlet does some stuff and forwards to create.jsp
BANG!  I GET THIS EXCEPTION (I have included some buildup to this
exception):

Now in Home servlet - processing request...
2002-03-08 13:19:08 - DecodeInterceptor: Charset from session ISO-8859-1
Now in Create servlet - processing request...
Getting list of available types seems to have went OK
2002-03-08 13:19:09 - Ctx(/AgentGenerator) : IllegalStateException in R(
/AgentGenerator + /create.jsp + null) - java.la
ng.IllegalStateException: Cannot forward because the response has already
been committed
        at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(Unknown
Source)
        at org.apache.tomcat.facade.RequestDispatcherImpl.forward(Unknown
Source)
        at zeus.generator.web.controllers.Home.goToAddress(Home.java:157)
        at zeus.generator.web.controllers.Home.processRequest(Home.java:120)
        at zeus.generator.web.controllers.Home.doGet(Home.java:131)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
        at org.apache.tomcat.core.Handler.invoke(Unknown Source)
        at org.apache.tomcat.core.Handler.service(Unknown Source)
        at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
        at org.apache.tomcat.core.ContextManager.internalService(Unknown
Source)
        at org.apache.tomcat.core.ContextManager.service(Unknown Source)
        at
org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown
Source)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown
Source)
        at java.lang.Thread.run(Thread.java:484)

But the page is being displayed OK, and the application continues to
function properly.  I'd just like to get rid of this exception somehow.
Maybe the way I am forwarding so much is not the best way to do things, but
it is working.  What alternatives are there?  Oh, I get the same sort of
messages when I substitute requestDispatcher.forward() with
response.sendRedirect().

Many thanks if anyone can assist,

Cheers

Lindsay



 -----Original Message-----
From: 	Ryan Daigle [mailto:RDaigle@healthdec.com] 
Sent:	08 March 2002 12:58
To:	'Tomcat Users List'
Subject:	RE: How can I resolve this "IllegalStateException: Response
has a lrea dy been committed" problem?

So at what point in this process are you getting this error?  I'm not sure I
understand the flow of the application, but it seems to be the pretty
standard jsp to servlet to jsp flow?

In my experiences, I usually get this error when I try to perform a redirect
within a jsp that has already started writing out to the response.  I don't
believe this is your scenario (based on your explanation).  Perhaps you are
redirecting or forwarding your response to another servlet/jsp and are then
trying to manipulate that response?  If so, you would need to do all
manipulation first, then forward your request on.


-Ryan

-----Original Message-----
From: lindsay.hamoudi@bt.com [mailto:lindsay.hamoudi@bt.com]
Sent: Friday, March 08, 2002 8:01 AM
To: tomcat-user@jakarta.apache.org
Subject: How can I resolve this "IllegalStateException: Response has
alrea dy been committed" problem?


[TOMCAT-3.3
JDK 1.3.1
WIN 2000]

Hi everyone,

I have a webapp that consists of various servlets - each of which is
associated with one or more JSPs.  The way it works is that someone logs in
(by calling a servlet which forwards them to the JSP form).  This servlet
then processes the input and then (upon successful authorisation) forwards
control to another servlet (which then displays another JSP and handles user
requests from this JSP).  This servlet then processes the user requests and
forwards control to the relevant servlet, which then forwards them to a JSP
page.

My application is working just fine, apart from the fact that I keep getting
these annoying "IllegalStateExceptions".  Here is the full exception:

2002-03-08 11:20:55 - Ctx(/AgentGenerator) : IllegalStateException in R(
/AgentGenerator + /servlet/Create + null) - java.lang.IllegalStateException:
Response has already been committed
        at
org.apache.tomcat.facade.HttpServletResponseFacade.sendError(Unknown Source)
        at
org.apache.tomcat.facade.HttpServletResponseFacade.sendRedirect(Unknown
Source)
        at zeus.generator.web.controllers.Home.goToAddress(Home.java:163)
        at zeus.generator.web.controllers.Home.processRequest(Home.java:120)
        at zeus.generator.web.controllers.Home.doGet(Home.java:131)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
        at org.apache.tomcat.core.Handler.invoke(Unknown Source)
        at org.apache.tomcat.core.Handler.service(Unknown Source)
        at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
        at org.apache.tomcat.core.ContextManager.internalService(Unknown
Source)
        at org.apache.tomcat.core.ContextManager.service(Unknown Source)
        at
org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown
Source)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown
Source)
        at java.lang.Thread.run(Thread.java:484)

2002-03-08 11:20:55 - ErrorHandler: Error loop for R( /AgentGenerator +
/servlet/Create + null) error java.lang.IllegalS
tateException: Response has already been committed


I have tried (and tried, and tried, ...)  to find some information on the
web, but have yet to find a solution.  It seems I can't forward more than
once from the same servlet, but I'm not even sure if I'm right about that.

If anyone can shed any light on this issue it would be most appreciated.

Thanks,

Lindsay

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message