This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes If a Session Timeout Will HttpSessionBindingListener Called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "If a Session Timeout Will HttpSessionBindingListener Called" Watch "If a Session Timeout Will HttpSessionBindingListener Called" New topic
Author

If a Session Timeout Will HttpSessionBindingListener Called

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
If a session is invalidated (timeout or explicitly calling invalidate()) does the attributes considered unbound and cause the HttpSessionBindingListener called?? This is not clearly defined in the spec which just say valueUnbound() is called when the attribute is "no longer available via the getAttribute() on the HttpSession inteface".

If the session itself no longer available, of course the getAttribute() also no long available. This seems to mean the valueUnbound() should also be called.
Jeremy Leong
Greenhorn

Joined: May 25, 2004
Posts: 5
I believe that all attributes are unbound and removed from the session when it invalidates(i.e. either programmtically or timed-out)

This is stated in HFSJ pg.242

From the servlet API

public void invalidate()
Invalidates this session then unbinds any objects bound to it.
[ September 28, 2005: Message edited by: Jeremy Leong ]
Jeremy Leong
Greenhorn

Joined: May 25, 2004
Posts: 5
The spec reads:

"Some objects may require notification when they are placed into, or removed
from, a session. This information can be obtained by having the object implement the HttpSessionBindingListener interface. This interface defines the following methods that will signal an object being bound into, or being unbound from, a session."

...

"The valueUnbound method must be called after the object is no longer available via the getAttribute method of the HttpSession interface." pg 39

the keyword that's being misread here is 'after' The section speicifies when actions are performed, and in the case of valueUnbound, it WILL be called when an object is unbound from a session, but ONLY after the attribute is unaccessible from the session.
[ September 28, 2005: Message edited by: Jeremy Leong ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: If a Session Timeout Will HttpSessionBindingListener Called
 
Similar Threads
HttpSessionBindingListener Problem in Tomcat 4.1.18
Doubt regarding Listeners
HFJS - final mock - q55
valueUnbound - when called?
HOW WILL I KNOW THAT THE BROWSER IS CLOSED?