Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Listener

 
Sharma Anjali
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HF S&J says only HttpSessionBindingListener need not be configured in DD rest all need to be configured.
But JQPlus says both HttpSessionBindingListener and HttpSessionActivationListener need not be configured in DD.

Which one is correct ?
 
Francois Roland
Ranch Hand
Posts: 34
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JQPlus is right.

The two interfaces HttpSessionActivationListener and HttpSessionBindingListener are directly implemented by object designed to be added as session attributes.

The other listener interfaces are used to send events to objects that are not designed to be used as attribute.
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I had the also experienced the same question in one of the mock exam in which they had asked to choose only one opiton from
HttpSessionBindingListener
HttpSessionActivationListener
HttpSessionListener

Cox many books also do say that only HttpSessionBindingListener needs to be configured in web.xml

Regards
Rohit
[ February 28, 2005: Message edited by: Rohit Bhagwat ]
 
Jose Esteban
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I repost my contribution to another recent thread about the same matter:

I think the Servlet 2.4 specs are a little confusing. They say in SRV.10.3.2:
"Listener classes are declared in the Web application deployment descriptor using the listener element."

which, I understand, means that all of the listeners must be declared in the DD.

But later, in SRV.15.1.10, the specs say:
"Events of this type are either sent to an object that implements HttpSessionBindingListener when it is bound or unbound from a session, or to a HttpSessionAttributeListener that has been configured in the deployment descriptor when any attribute is bound, unbound or replaced in a session."

which seems to indicate that HttpSessionBindingListener doesn't need (have) to be declared in the DD.

I really would appreciate any explanation.

What HFSJ say is that:
"...HttpSessionActivationListener must be registered in the DD, since they are related to the session itself, rather than an individual attribute placed in the session"

What about ServletRequestListener or ServletRequestAttributeListener? I think they must be declared in the DD, but I dont know it for sure.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!