Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference b/w HttpSessionBindingListner and HttpSessionAttributeListner

 
ahmed, ishtiaq
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5382
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic