File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in Listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in Listener" Watch "Doubt in Listener" New topic
Author

Doubt in Listener

Gorkal Raghavendra
Ranch Hand

Joined: May 21, 2008
Posts: 30
Whats the difference b/w HttpSessionAttributeListener and HttpBindingListener.
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
An HttpSessionAttributeListener is normally implemented by an non-attribute class when an associated object needs to know that an attribute has been added to, replaced, or removed from a given session.

An HttpSessionBindingListener is normally implemented by an attribute class when an associated object needs to know that it is bound to or unbound from a session.
Kunal Jag
Ranch Hand

Joined: Jun 08, 2008
Posts: 31
The key difference between HttpSessionBindingListener and HttpSessionAttributeListener is that in case of the former, a class itself receives notifications when it's bind to a session or unbind from a session object. Whereas, the HttpSessionAttributeListener is like a generic listener, which can be used to track all attributed which are added, removed or replaced in a session.


Regards,
[ July 04, 2008: Message edited by: Kunal Jag ]

Kunal Jaggi<br />Author of <a href="http://www.tatamcgrawhill.com/html/titleDetail.jsp?isbn=9780070249103.html" target="_blank" rel="nofollow">"SCWCD Exam Guide"</a>, SCWCD 5 (exam 310-083 and 310-084), <a href="http://www.tatamcgrawhill.com/html/titleDetail.jsp?isbn=9780070249103.html" target="_blank" rel="nofollow">McGraw-Hill</a><br /><a href="http://javaevangelist.com/" target="_blank" rel="nofollow">http://javaevangelist.com/</a><br /><a href="http://www.oreillynet.com/pub/au/2669" target="_blank" rel="nofollow">http://www.oreillynet.com/pub/au/2669</a>
vishalraju shah
Greenhorn

Joined: Oct 06, 2007
Posts: 19
They both are declared differently,(This may appear in exam where you are gievn a exhibit and asked to choose which interface declaration is valid or not valid with given DD).

HttpSessionBindingListener doesn't need to be in DD (web.xml). Any object can implement this listener interface and provide impl. for valueBound and valueUnbound methods.

HttpSessionAttributeListener needs to be define in DD as and class has to provide impl. for it's methods.
<listener>
<listener-class>com.abc.MySessionAttributeListener</listener-class>
<listener>

They both share same event - HttpSessionBindingEvent.


SCJP1.4 (92%), SCWCD (85%), SCBCD (81%), SCEA-I (In Progress)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Listener