| Author |
HttpSessionBindingListener Interface
|
Shrinivas Mujumdar
Ranch Hand
Joined: Aug 27, 2004
Posts: 328
|
|
Can anybody help me out in understanding a practical example for implementing a HttpSessionBindingListener Interface?(when you have HttpSessionAttributeListener) There is one more thing that you don't have to make a entry in web.xml for the same (alike other Listeners) why it is so? Thanx in Advance Shrinivas
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
|
http://www.coderanch.com/t/166658/java-Web-Component-SCWCD/certification/HttpSessionAttributeListener-vs-HttpSessionBindingListenter
|
Groovy
|
 |
Shrinivas Mujumdar
Ranch Hand
Joined: Aug 27, 2004
Posts: 328
|
|
Agreed!!! Now what is the practical example of using HttpSessionBindingListener? Shrinivas
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
There is one more thing that you don't have to make a entry in web.xml for the same (alike other Listeners) why it is so?
The reason is that when an object is added to or removed from any session, the container introspects the interfaces implemented by that object. If the object implements the HttpSessionBindingListener interface, the container invokes the valueBound or valueUnbound methods respectively. These methods are called even if the session is explicitly invalidated or timed out. The arg passed into the methods is of type HttpSessionBindingEvent. The developer can do various things in these methods. For instance, in valueBound the HttpSession associated with the HttpSessionBindingEvent can be obtained.
|
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by Shrinivas Mujumdar: Agreed!!! Now what is the practical example of using HttpSessionBindingListener? Shrinivas
Consider this : If session timeout and login info is stored as HttpSessionBindingListener object the value unbound method will be called. You could this method for example log some auditing messages that user has been logged out because of timeout.
|
 |
 |
|
|
subject: HttpSessionBindingListener Interface
|
|
|