Win a copy of Pragmatic AI this week in the Artificial Intelligence 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

AttributeListeners VS BindingListeners  RSS feed

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some problems understanding the difference in functionality provided by the HttpSessionAttributeListener interface and the HttpSessionBindingListener interface. Does anyone have an easy way of differentiating the roles of the above named interfaces?
 
Ricardo Cortes
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I think I finally figured it out. Correct me if I am wrong. If I have an object aBook of type Book, then HttpSessionAttributeListener will send out a notification when an object has been added, replaced or removed from the session whereas HttpSessionBindingListener will send out a notification (as long as Book implements the HttpSessionBindingListener interface) when aBook has been bound or unbound from the session. Is this a correct?
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ricardo, this is a great question.
The only comment I can add is when you alter a session-level object (add/modify/remove) and the object implements HttpSessionBindingListener, the container calls the valueBound method and then notifies the appropriate HttpSessionAttributeListener(s).
I've also tried writing some sample code to fully understand the distinction, but so far, it hasn't caused the proverbial light to come on.
 
Ricardo Cortes
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, in other words, if I want to monitor the adding/removing/replacing of objects to the session I use HttpSessionAttributeListener and I want to monitor changes to a specific object's values then I have that object implement HttpSessionBindingListener?
 
Ricardo Cortes
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I never realized how good the search function of this messageboard really was...I did some searching and found several posts on the subject, including this one:
http://www.coderanch.com/t/164328/java-Web-Component-SCWCD/certification/difference-HttpSessionBindingListner-HttpSessionAttributeListner
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!