wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Regarding Listeners Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Regarding Listeners" Watch "Regarding Listeners" New topic
Author

Regarding Listeners

Mathew Sam
Ranch Hand

Joined: Dec 19, 2001
Posts: 124
After session invalidation, HttpSessionListener is notified.Prior to that will the container notify the HttpSessionAttributeListener and HttpSessionBindingListener ? Because before invalidation of the session ,session attributes have to be removed.
regards,
Sam
Kyle Tang
Ranch Hand

Joined: Aug 22, 2002
Posts: 78
yes. web-container should notify HttpSessionBindingListeners and HttpSessionAttributeListeners, before HttpSessionListen got the sessionDestroyed().
in the sessionDestroyed(), session.getAttribute() will be illegal, I forget whether it will throw an exception.


Kyle Tang<br />SCJP 91<br />SCWCD 96<br />SCBCD 95
jeffrey z. lee
Ranch Hand

Joined: Mar 21, 2002
Posts: 40
are the Attributes in session removed when session is Destroyed?


jeffrey z. lee
Kyle Tang
Ranch Hand

Joined: Aug 22, 2002
Posts: 78
That's good question.
I am not for sure now, it is not on top of my head, but I have the impression that if the attribute implements HttpSessionBindingListener, they should get notified before the HttpSessionListener got sessionDestroyed() called.
If I have time later I will check the servlet spec. In the mean time I suggest you also take a look in the spec. One thing I still remember is "SCWCD study kit" says in sessionDestroyed() you can't call session.getAttribute(), that means all attributes should have been removed from that session.
Maha Annadurai
Ranch Hand

Joined: Oct 27, 2002
Posts: 87
Here is the order in which the listeners will be invoked.
1. HttpSessionListener.sessionCreated(..)
2. HttpSessionBindingListener.valueBound(..)
3. HttpSessionAttributeListener.attributeAdded(..)
4. HttpSessionBindingListener.valueUnbound(..)
5. HttpSessionAttributeListener.attributeRemoved(..)
6. HttpSessionListener.sessionDestroyed(..)
Regarding the other question, if we invoke a method on HttpSession object inside sessionDestroyed(..) of HttpSessionListener method, we will get IllegalStateException.
Regards,
Maha Anna
Timber Lee
Ranch Hand

Joined: Oct 14, 2002
Posts: 157
is the order related to the listener of deployment desription?


SCJP<br />SCWCD<br />SCEA
Maha Annadurai
Ranch Hand

Joined: Oct 27, 2002
Posts: 87
The listed order above is for a particular case of removing a session attribute which implements the HttpSessionBindingListener and we also have a HttpSessionListener and a HttpSessionAttributeListener configured in web.xml.
Regards,
Maha Anna
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Listeners