• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

difference b/w HttpSessionBindingListner and HttpSessionAttributeListner

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic