This week's giveaway is in the Cloud/Virtualization forum. We're giving away four copies of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP and have Lucian Maly on-line! See this thread for details.
For one thing, the HttpSessionBindingListener interface solves a problem related to the handling of user session invalidation. A session can become invalidated by: 1. The action of your servlet - when a user logs out 2. The action of the servlet container - at expiration of the timeout If you have an object that has to do some "cleanup" before it is discarded, have it implement HttpSessionBindingListener. Bill
Originally posted by William Brogden: For one thing, the HttpSessionBindingListener interface solves a problem related to the handling of user session invalidation. A session can become invalidated by: 1. The action of your servlet - when a user logs out 2. The action of the servlet container - at expiration of the timeout If you have an object that has to do some "cleanup" before it is discarded, have it implement HttpSessionBindingListener. Bill
I think HttpSessionListener for what you meant.
HttpSessionBindingListener is typically used to get notified when a object is set in or removed from session scope using setAttribute or removeAttribute method of HttpSession.
is it not always called back whenver we manipulate the session object?
Did I misunderstand that? [ June 13, 2006: Message edited by: Dilip Kumar Jain ]
The HttpSessionBindingListener can be used for objects that you plan to store into your session attributes, so they know when they are attached as a session attribute (with session.setAttribute).
In general anything that you would need to do when something when it is placed onto, or removed from a session attribute could do its own handling when it implements this interface.
One example might be a component that would be set into the session when the session is created or a user logs on, and would stay there the entire time the user is logged in, or the lifetime of the session. This component could log a message to a user activity log when in the valueBound() method, when it was placed onto the session attribute, and log another user logged out message in the valueUnbound, when the component got removed from the session attributes, such as on log out or when the session was destroyed.
Another example might be if you were storing a connection handle to an external resource for the session, such as database connection per session, the connector component could implement HttpSessionBindingListener to clean up its resources when it is removed from the session (and would not be needed by application anymore)
Objects that implement this interface do not have a listener deployment entry in the web.xml.
This is similar to HttpSessionActivationListener, where implementations get notified when servlet container activates or deactivates the session, which happens when a web application is reloaded, or in a cluster environment when the session is being transferred to other nodes in the cluster.
Error: Keyboard not attached. Press F1 to continue.