Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSessionBindingListener Interface

 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed!!!
Now what is the practical example of using HttpSessionBindingListener?

Shrinivas
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic