aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Session Listener 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 "Session Listener" Watch "Session Listener" New topic
Author

Session Listener

Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213
This is a question from HF book chapter 6 coffee cram exam

Which method(s) can be used to ask the container to notify your application whenever a session is about to timeout? (Choose all that apply.)
A. HttpSessionListener.sessionDestroyed
B. HttpSessionBindingListener.valueBound
C. HttpSessionBindingListener.valueUnbound
D. HttpSessionBindingEvent.sessionDestroyed
E. HttpSessionAttributeListener.attributeRemoved
F. HttpSessionActivationListener.sessionWillPassivate


The Answer given is A and C

But what I think is E should also be notified

the explanation/reason given for Option E which is not correct : removing an attribute isn’t tightly associated with a session timeout

May I know what is the meaning of "isn’t tightly associated with " ??

Thanks.


SCJP 6, SCWCD 5, SCBCD 5
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Well the answer is simple. HttpSessionAttributeListeners are not notified when a session is about to timeout. HttpSessionListeners are made only to be notified about session state. And if you check the API Docs of HttpSessionBindingListener, then this is mentioned specifically there

Causes an object to be notified when it is bound to or unbound from a session. The object is notified by an HttpSessionBindingEvent object. This may be as a result of a servlet programmer explicitly unbinding an attribute from a session, due to a session being invalidated, or due to a session timing out.


This must be mentioned in the servlet specification too but I've not read that so can't tell you the exact section...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Listener