• Post Reply Bookmark Topic Watch Topic
  • New Topic

jdiscuss question

 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because there is httpsessionattributelistener.

httpsessionbindinglistener only tells if a new attribute is bound or some attribute is unbound from the session.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Sergey Tyulkin
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!