wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Session" Watch "Session" New topic
Author

Session

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
This is a simple program I wrote to test whether the session is new or old.
What I cant get is , after I call session.invalidate() , how are the lines after session.invalidate being run.
like printing out the values of attribute.
Also , the session object is the same .




The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

You've already taken out the attributes out from the session before invalidating it. Try calling session.getAttribute after invalidating it, you'll get an IllegalStateException...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Invoking getAttribute() after invalidate() will definitely cause a runtime exception ,
But doesn't the attrbute value get destroyed when the session is invalidated??

priya rishi
Ranch Hand

Joined: Oct 26, 2008
Posts: 119
But doesn't the attrbute value get destroyed when the session is invalidated??


you are storing them in the String Objects , nothing happens to the String objects.

Only the attributes which belonged to the session is no longer available.


SCJP 5 , SCWCD 5
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
That explains it. Thanks Priya !!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session
 
Similar Threads
Url Rewriting
IllegalStateException Question from Head first Servlets
session listeners
How to disable cookies
Synchronizing Http Session attributes