• 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

Regarding HttpSessionAttributeListener and HttpSessionBindingListener

 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone please tell about the difference between HttpSessionAttributeListener and HttpSessionBindingListener?

I checked in Head First Servlet Servlet and JSP. It tells

"A plain old HttpSessionAttributeListener is just a class that wants to know when any type of attribute has been added, removed or replaced in a Session. But the HttpSessionBindingListener exist so that the attribute itself can find out what when it has been added to or removed from Session."

Does it mean that HttpSessionAttributeListener tell about any attribute. While HttpSessionBindingListener gives information about attribute itself NOT any other attribute?

Is my understanding right?

Please help me for above concepts.

Thanks Jay.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. your understanding is correct. httpSessionBindingListener is for when a particular object wants to be notified when it has been added to the session.
 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry Ranchers , I cant' find the better opportunity to extend the Thread ,What do you mean by a particular Object as Servlet is a ThreadBased and for every Thread the Object will be unique so my doubt is how this is achieved.

sorry once again for not posting a new topic.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RaviNada the concept is not about a particular Servlet object. It is about a particular object that is added or removed from the Session. Suppose I implement a class which implements the HttpSessionBindingListener interface. Now when I add an object of that class into a session, the valueBound method of my class will be called. Similarly when an object of my class is removed from a session, then the valueUnbound method of my class will be called...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic