This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes Session already invalidated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session already invalidated" Watch "Session already invalidated" New topic
Author

Session already invalidated

Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Hello All -

I'm not able to find out what's causing this error.


type : Exception report

message :

description : The server encountered an internal error () that prevented it from fulfilling this request.

exception :

java.lang.IllegalStateException: getAttribute: Session already invalidated
org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:984)
org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:109)
Main.doGet(Main.java:60)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)


note : The full stack trace of the root cause is available in the Apache Tomcat/5.5.8 logs.


Am I using the session wrong way ? Really appreciate any suggestions. Thanks

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You problem is that the session is an instance variable, there is only one variable and all of your rerquests end up sharing it. Move it inside the method instead so there will be one per thread instead.

Dave
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Dave, Thanks for the responese.

I'm little bit puzzled about sessions. I would like to set some default values to session variables when the user first time comes to the web page via servlet. Later the values for session variables chaanges based on user selecting differing parameters. If I move HttpSession session; inside the
goGet how I do I know whether it is new seesion of existing session.

Thanks again.
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
I will try

HttpSession session = req.getSession(true);

if (session.isNew()) {

} else {

}

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session already invalidated