wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes difference b/w HttpSessionBindingListner and HttpSessionAttributeListner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "difference b/w HttpSessionBindingListner and HttpSessionAttributeListner" Watch "difference b/w HttpSessionBindingListner and HttpSessionAttributeListner" New topic
Author

difference b/w HttpSessionBindingListner and HttpSessionAttributeListner

ahmed, ishtiaq
Greenhorn

Joined: Aug 02, 2001
Posts: 6
i wana know what is the difference b/w HttpSessionBindingListner and HttpSessionAttributeListner.
they i think have the same functionality (method)
attributeAdded() --- valueBound()
attributeRemoved() --- valueUnbound()
attributeReplaced()

plz any one explain
syed ishtiaque ahmed
SCJP2
satish kolli
Greenhorn

Joined: Sep 21, 2001
Posts: 24
They look the same as they generate the same event.
But the way they respond varies.
HttpSessionBindingListener - will notify the objects that
1. Implement this listener and
2. Are added to a session.
3. This will not notify the objects that implement this listener but are not added to the session.
4. Session Specific
HttpSessionAttributeListener - will notify the object that
1. implemetns this interface.
2. The object in question need not be a part [i.e added to the session] of the session to receive this notification.
3. Works accross sessions
4.notify the CONTAINER when you add/remove/replace an object from a session.
Good Tutorial on Listeners: http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html?page=1
Satish Kolli
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
An object that implements HttpSessionAttributeListener (and is registered as a listener in web.xml) is notified anytime any object is added/removed/replaced in any session in the web application context. This is useful for an administrative console, for instance, that would allow an admin to view all session attributes across the application.
An object that implements HttpSessionBindingListener is notified anytime when that object itself is added to or removed from any session in the web application context. This is useful, for instance, if an object should log whenever it is bound to or unbound from a session.
------------------
Miftah Khan
- Sun Certified Programmer for the Java 2 Platform
- Sun Certified Web Component Developer for the J2EE Platform
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
May I say that
HttpSessionAttributeListener works at WebApplication level.(then object which implements it should exist through out the application i.e. should be in ServletContext)
HttpSessionBindingListener works at session level.
Plz correct me if I am wrong


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: difference b/w HttpSessionBindingListner and HttpSessionAttributeListner