This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jdiscuss question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jdiscuss question" Watch "jdiscuss question" New topic
Author

jdiscuss question

Jingh Yi
Ranch Hand

Joined: Mar 23, 2005
Posts: 90
Associate the events with appropriate listener interface:

When an attribute is replaced in the session:

a. HttpSesionActivationListener
b. HttpSessionBindingListener
c. HttpSessionListener
d. None of these




Answer is d. Why not b?
kapil munjal
Ranch Hand

Joined: May 11, 2004
Posts: 298
because there is httpsessionattributelistener.

httpsessionbindinglistener only tells if a new attribute is bound or some attribute is unbound from the session.


Kapil Munjal
SCJP 1.4, SCWCD 1.4
Jingh Yi
Ranch Hand

Joined: Mar 23, 2005
Posts: 90
But HttpSessionBindingListener does listen to attribute replacement. Like in the following HttpServlet:

The HttpSessionBindingListener class:


When the dog1 is replaced by dog2, HttpSessionBindingListener does print out lines.

Why is it not correct answer?

Thanks,
Jenny
Regis Santos
Ranch Hand

Joined: Mar 23, 2004
Posts: 31
Jenny,

The listener HttpSessionBindingListener is for the object to know when it has been added (bound) or will be removed (unbound) in a session.

If you want to know when anything has been added, replaced or removed as an attribute in a session, you have to use HttpSessionAttributeListener. Pay attention: HttpSessionAttributeListener must be declared in the DD.

In you example, the Dog implements HttpSessionBindingListener and it is notified when it is added or removed in a session.

Regards,


Regis Santos
Sergey Tyulkin
Ranch Hand

Joined: May 10, 2005
Posts: 87
What mock exam do you use. I saw similar question in EnthuWare mock exam, and people on their forum says that HttpSessionBindingListener is a correct answer for such questions.
We can only hope not to encounter such questions in the real exam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdiscuss question
 
Similar Threads
A EL Question
JSP page translation issue
Package
mock exam question
Mock exam question