Win a copy of Rust Web Development this week in the Other Languages 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

What's the difference between HttpSessionAttributeListener and HttpSessionBinding...

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the following is executed:

session.setAttribute("newAttribute", "value"); //newAttribute is a totally new Attribute

What happen?
I've been told that the HttpSessionBindingListener can be notified. How about the "HttpSessionAttributeListener" which has the "attributeAdded" method? Will it be notified?
Thanks for reply!
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
SessionAttributeListeners are used when any attribute is bound, removed or replaced in session. But sessionBinderListener is used when only particular att
If you want to track any attribute added, removed or replaced in session you need to implement SessionAttributeListener. Any attribute in this scenario means, of any datatype viz, String, Integer, Products(Custom).
To do this, we need to create a class which implements the SessionAttributeListener and implement the 3 methods. Anytime, any attribute is added, remove, replaced, the corresponding events will be fired by the container.
However, if you have a class say Product, and you want to track any instance of Product added to session, then you have implement SessionBinderListener on Product class. ie.
public class Product implements SessionBinderListener
and you need to implement the corresponding methods.
So anytime, a instance of product is added to session, then the corresponding methods viz sessionBound() etc will be called by the container.
I guess it helps.
Regards,
Vijay
 
Hua Liang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijay Sargunam, Thanks a lot! Now I got it!
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
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
reply
    Bookmark Topic Watch Topic
  • New Topic