aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes clarification Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "clarification" Watch "clarification" New topic
Author

clarification

Nitin Gogia
Greenhorn

Joined: Jan 17, 2003
Posts: 22
i was taking javaranch mock exam and came across the following question :-
A class that will recieve notification if an Attribute is added to or removed from a session will implement which interface?
What is the correct answer for this.
According to me it shud be HttpSessionBindingListener but it mentioned the correct answer as HttpSessionAttributeListener (i did not choose this because class implementing this interface has to be specified in DD).
Please clarify and help me in clearing my doubt.
Kevin Mukhar
Ranch Hand

Joined: Nov 28, 2000
Posts: 83
The correct answer is HttpSessionAttributeListener.
HttpSessionBindingListener is implemented by an object so that the object itself will be notified if it is bound or unbound to a session. That will not work for all objects (for instance, String does not implement this interface, so a String instance can't be notified when it is added to a session).
HttpSessionAttributeListener is implemented by a class when that class wants to be notified that any attribute has been added to the session. That is the other difference: HttpSessionBindingListener can only notify a specific object that it has been added; HttpSessionAttributeListener is notified when any attribute has been added.
So, when you develop a class that is to be notified when any attribute is added to a session, you would implement HttpSessionAttributeListener, and then register that class through the listener element of the deployment descriptor. The listener element takes the fully qualified name of the class, not the listener interface.
[ January 20, 2003: Message edited by: Kevin Mukhar ]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: clarification
 
Similar Threads
Anonymous class..
A minor confusion about constants..
inner class
Inner class extends
Inner class question