So because the specs have mentioned means we cannot use it for notification ?
I suppose you meant "because the specs did not mention...."
Yes, we cannot rely on the notification if the specifications don't specify that it should happen (as with the HttpSessionBindingListener) But that doesn't mean that it won't be implemented, it just means that the servlet-container-developers can choose an implementation. ( and if you rely on one implementation, your application won't be portable to another provider just like that)
Suppose if i have implemented both the listeners and when ever an attribute is removed,then first the attributeRemoved() is called which further makes call to valueUnbound().I had read this somewhere but not able to recollect it properly.So just correct me if i am wrong.
Yes, this is where you can find that in the Servlet 3.0 specs:
7.4 Binding Attributes into a Session
Some objects may require notification when they are placed into, or removed from, a session. This information can be obtained by having the object implement the
HttpSessionBindingListener interface. This interface defines the following methods that will signal an object being bound into, or being unbound from, a session.
- valueBound
- valueUnbound
The valueBound method must be called before the object is made available via the getAttribute method of the HttpSession interface. The valueUnbound method must be called after the object is no longer available via the getAttribute method of the HttpSession interface.
Regards,
Frits