File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes HttpSessionBindingListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSessionBindingListener" Watch "HttpSessionBindingListener" New topic


Bharatesh H Kakamari
Ranch Hand

Joined: Nov 09, 2000
Posts: 198
What is HttpSessionBindingListener interface ? Where is it used ?
lokesh reddy
Ranch Hand

Joined: Sep 15, 2000
Posts: 66

Hi Bharat,
HttpSessionBindingListener is an interface specifically used for session management.
If u want to know when the session is binded and unbinded, then u have to implement a class with this interface and use it in your servlet.
This interface has two methods 1) valueBound 2) valueUnBound
Implementing this two methods, u can do some useful work like whenever a session is binded, u can load the user related file in to memory and perform some actions on it, and when ever the session ends you can save the data back.
I hope u find this info useful.
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Not entirely accurate
HttpSessionBindingListener is not so much about session lifetime as about the lifetime of session-scoped objects.
You can implement the HttpSessionBindingListener in any object you want to bind in the session. If you do, your object will be alerted when it is bound to a session, and when it is unbound for whatever reason (session expiration or a removeAttribute call).
This is useful if the object needs to do some initialisation or clean-up, such as managing external resources or the co-ordinated (un)binding of related session scoped objects.
- Peter
I agree. Here's the link:
subject: HttpSessionBindingListener
It's not a secret anymore!