aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes What's the difference between HttpSessionAttributeListener and HttpSessionBinding... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "What Watch "What New topic
Author

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

Hua Liang
Greenhorn

Joined: Dec 24, 2003
Posts: 4
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!
Vijay Sargunam
Greenhorn

Joined: Jan 14, 2004
Posts: 11
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

Joined: Dec 24, 2003
Posts: 4
Vijay Sargunam, Thanks a lot! Now I got it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's the difference between HttpSessionAttributeListener and HttpSessionBinding...
 
Similar Threads
Session Listeners
Regarding Listener Concept
clarification
******HttpSessionBindingEvent doubt!!!!*******
session.invalidate()