• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSessionBinding listener

 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When does this binding listener gets notified...???
 
Abhijit Rai
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Lets assume there is a class A which implements this interface ,so it has two methods in it ie valueBound and valueUnbound.
Whenever we make an object of class A ,lets say B,that object B has these two methods available to it .
Now if we add B to a session ,the container calls B's sessionBound method prior to binding it to the session and when B is to be removed from the session the container calls its unBound method prior to unbinding it from the session.
Thus these two methods provide us the oppertunity to take any actions required prior to the attribute being bound to a session and then later released from it.
 
Sarat Koduri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats really fantastic explanation Abhijit..
 
Jan Sterk
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, good explanation.

Still one more question.. Will unbound() also be called if the session is destroyed?
 
Sarat Koduri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i gues..it will be notified . what do you say Abhijit
..
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add what other ranchers are talking..

HttpSessionBindingListener: When an class implementes this interface it
Causes an object to be notified when it is bound to or unbound from a session.
The object is notified by an HttpSessionBindingEvent object. This may be as a
result of a servlet programmer explicitly unbinding an attribute using removeAttribute of HttpSession or due to a session being invalidated using HttpSession.invalidate() , or due to a session timing out.

Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic