tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <>
Subject Re: In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed
Date Thu, 23 Sep 2010 18:11:22 GMT
On 23/09/2010 07:42, Brian wrote:
> What does "response has been commited" mean? I have a theory: Maybe it means
> that in the java code that the container generated for my JSP, at least one
> "out.write()" method has already been used, which means that "It already has
> started to send html code to the browser". Am I right? 
> Again, this is a sporadic issue, which drives me crazy!

"committed" means that the HTTP headers have been written to the client
and no further headers can be sent (note: creating a session requires
sending a cookie header to the client - this will be important in a
bit). Output is buffered (I think 8k by default - might be 4k) by
default so you can still add headers even after some content has been

JSPs create sessions by default unless you explicitly disable this.

I suspect the sequence is:
1. Your page starts processing
2. The page is committed (either it calls flush or the output fills the
buffer so it has to flush)
3. Something goes wrong
4. Redirect to error JSP
5. Error JSP tries to create a session
6. Response has been committed so session can't be created
7. You get the error you are seeing

If step 3 occurs before step 2 then everything will work as the response
won't have been committed.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message