This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in session

 
Ahmed Shaikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic