aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes session.invalidate() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "session.invalidate()" Watch "session.invalidate()" New topic
Author

session.invalidate()

Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 152
i ran a program...and then destroyed the session...i think all the attributes associted with the session are also killed when the session is destroyed...unbound is being called for each of the attributes....

is this right? or did i explain it wrong?


Do What You Wanna Be....Taking Things The Way They Come
scjp 1.6 91 percent, scmad 90 percent(rounded off to nearest integer)
Christophe Verré
Marshal

Joined: Nov 24, 2005
Posts: 14361

Yes, attributes will be unbound when the session is invalidated.


[SCBCD Wall of Fame] [My Blog]
All roads lead to JavaRanch
Help Japan. Make a donation.
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

But i think that the listener associated with the attributes will not be called in that case.

Correct me if i am wrong.
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 152
when the session is destroyed...first the HttpSessionBindingListener is called...and then the HttpSessionAttributeListener
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

I tried it but HttpSessionAttributeListener was not being called when session was invalid.

I think i have to re verify it.
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 152
it does get called...i tested it just now
Christophe Verré
Marshal

Joined: Nov 24, 2005
Posts: 14361

I'm not sure about HttpSessionAttributeListener, but HttpSessionBindingListener will be notified.
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 152
how can i be wrong then..i just tried it
Christophe Verré
Marshal

Joined: Nov 24, 2005
Posts: 14361

how can i be wrong then..i just tried it

Nobody is saying that you are wrong. However, "The container I'm using does it this way, so it works that way" is not a good argument. Containers sometimes do things unconventional things.
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

Can both of you please let us know the containers you are using ?
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 152
is it because am using tomcat 6? what if tis question comes in the exam?
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

Yes, first HttpSessionBindingListener and then HttpSessionAttributeListener is being called.

I have tested it on TomCat 6
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 152
thank god..thank you
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

But we have to test it again on an earlier version of TomCat
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 152
actually i have read it here that the exam uses tomcat 5..i thought it woudnt matter....but am not changing any risk...switcing to 5.5
 
 
subject: session.invalidate()
 
Threads others viewed
Servlets and session...Do I need to?
Regarding Listeners
session invalidation
Session Migration Pg 269 HFSJ
session listener
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture