aspose file tools*
The moose likes Servlets and the fly likes problem in session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem in session" Watch "problem in session" New topic
Author

problem in session

Ahmed Shaikh
Ranch Hand

Joined: Jul 25, 2005
Posts: 51
Hi,
In my application after few min it throws this exception..
java.lang.IllegalStateException: Cannot create a session after the response has
been committed
at org.apache.coyote.tomcat5.CoyoteRequest.doGetSession(CoyoteRequest.ja
va:2270)
at org.apache.coyote.tomcat5.CoyoteRequest.getSession(CoyoteRequest.java
:2116)
at org.apache.coyote.tomcat5.CoyoteRequestFacade.getSession(CoyoteReques
tFacade.java:526)

plzzzz help me in solving this problem.
Thanx
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The session gets set in the the HTTP header, which is the first bit sent to the client. The reposnse is buffered until the buffer is filled and then the header gets sent to the client. At this stage it is too late to tell it you suddenly want a session.

Try calling the session earlier, even if you don't use it. THis will make sure it exists later on.

Dave
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
Hi Ahmed,

I have not tested myself but I guess your are probably doing this:

out.println("<html>...")
out.println...
out.println...
out.println...

HttpSession session=request.getSession();

You previous out.println() have caused the output buffered flushed automatically (and the response committed).
 
jQuery in Action, 2nd edition
 
subject: problem in session