File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Session Invalidation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session Invalidation" Watch "Session Invalidation" New topic

Session Invalidation

Krishna, Alle

Joined: Nov 16, 2001
Posts: 14
Hi All,
I wanted to know when a session is invalidated with a HttpSession.invalidate() call, is the session object destroyed or are all the objects associated with the session are destroyed?
Snippet of the code I have in a JSP,
String inv = request.getParameter("action");
if(inv != null && inv.equals("invalidate")) {
session = request.getSession(true);
System.out.println("SESS = " + session);
String sessionAttr1 = (String)session.getAttribute("uid");
I get an IllegalStateException when the getAttibute method in the above piece of code is executed. But, I can see the print statement SESS shows a session.
FYI: I am using Orion Application Server, ver 1.5.2
Can someone let me know the answer. I appreciate the response in advance. Let me know if the question is ambiguous.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13035
I believe it works this way. When you call session.invalidate, the system detaches all items attached to the session object and marks it as an invalid session. Subsequently all session method calls then throw that exception. The servlet engine can't null out all references to the session until after the current request/response cycle is finished so the object is still there.
Krishna, Alle

Joined: Nov 16, 2001
Posts: 14
Thank you for the information. So is this some kind of limitation the Session Management API.
Once again, Thanks
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
hi Krishna
to be on safe side i'd have written,

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