aspose file tools*
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 Spring in Action this week in the Spring 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: 9305
    
  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 !!!
 
Consider Paul's rocket mass heater.
 
subject: Session