Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jdiscuss question" Watch "jdiscuss question" New topic

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?

Regis Santos
Ranch Hand

Joined: Mar 23, 2004
Posts: 31

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.


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:
subject: jdiscuss question
It's not a secret anymore!