File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in Listener" Watch "Doubt in Listener" New topic

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.

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

Kunal Jaggi<br />Author of <a href="" target="_blank" rel="nofollow">"SCWCD Exam Guide"</a>, SCWCD 5 (exam 310-083 and 310-084), <a href="" target="_blank" rel="nofollow">McGraw-Hill</a><br /><a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a>
vishalraju shah

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.

They both share same event - HttpSessionBindingEvent.

SCJP1.4 (92%), SCWCD (85%), SCBCD (81%), SCEA-I (In Progress)
I agree. Here's the link:
subject: Doubt in Listener
It's not a secret anymore!