HttpSessionBindingListener: You Have one class that you are going to set in session,
If you want to notification when that class bound & unbound to session then that class must implement HttpSessionBindingListener & override 2 methods of that class that are going to call when object is bound & unbound.
HttpSessionAttributeListener: This is genaral Interface we need to Implement it by our own class override methodes of this interface & decleare our clas in in web.xml.
after that when attrbute is added, removed & replaced pericular method of our class is called accordingly.
Hope this will help you.
Joined: Feb 28, 2009
But my questions still remains the same what is the scenario you would tell a Object that it has been bounded/unbounded to the session??
Joined: Jul 10, 2008
Suppose UserInfoObj is class Implementing HttpSessionBindingListener Interface
UserInfoObj have many properties like name, address,phone number etc,
we are storing UserInfoObj into Database table USER_INFO.
Now when this (UserInfoObj) put into session, valueBound method is called(we overrided this method in UserInfoObj)
in this method we can get data from USER_INFO table & store into UserInfoObj.
when we remove UserInfoObj from session valueUnbound is called, there we can store data from UserInfoObj into USER_INFO table.