Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

jdiscuss question

 
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?
 
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
 
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,
 
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
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic