File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session already invalidated" Watch "Session already invalidated" New topic

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

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

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.

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 {


I agree. Here's the link:
subject: Session already invalidated
It's not a secret anymore!