This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

difference b/w HttpSessionBindingListner and HttpSessionAttributeListner

 
Greenhorn
Posts: 6
  • 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
 
Greenhorn
Posts: 24
  • 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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • 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
 
Ranch Hand
Posts: 5390
1
Spring Java
  • 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
 
Screaming fools! It's nothing more than a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic