Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listeners with no DD entry

 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which listerners do not require any entry in the DD?
 
Tripati Sahu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think HttpSessionActivationListener doesn't reqd to be placed in DD.

Guys, please correct me if I am wrong.
 
Mateus Lucio
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpSessionActivationListener and HttpSessionBindingListener doesn't need to be placed in web.xml because these listener notify the objects that are bound to a session and not the session itself.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this FAQ.
 
Oleksandr Usatyy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I remember only HttpSessionBindingListener should not be declared in web.xml.
Other listeners (HttpSessionActivationListener also) should be declared.

Sorry maybe I'm wrong because I saw a lot diff posts about this topic. One of them is following (Head First Servlet & JSP 2-nd edition page 256)
"HttpSessionListener and HttpSessionActivationListener must be registered in the DD, since they’re related to the session itself, rather than an individual attribute placed in the session."


 
Kosala W.Abayagunawardene
Ranch Hand
Posts: 47
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oleksandr Usatyy wrote:As I remember only HttpSessionBindingListener should not be declared in web.xml.
Other listeners (HttpSessionActivationListener also) should be declared.

Sorry maybe I'm wrong because I saw a lot diff posts about this topic. One of them is following (Head First Servlet & JSP 2-nd edition page 256)
"HttpSessionListener and HttpSessionActivationListener must be registered in the DD, since they’re related to the session itself, rather than an individual attribute placed in the session."




You are right.
Book says...

===============================
You do NOT confi gure session
binding listeners in the DD!

If an attribute class (like the Dog class here) implements the
HttpSessionBindingListener, the Container calls the event-
handling callbacks (valueBound() and valueUnbound()) when
an instance of this class is added to or removed from a session.
That’s it. It just works. But this is NOT true for the other session-
related listeners on the previous page. HttpSessionListener
and HttpSessionActivationListener must be registered in the
DD, since they’re related to the session itself, rather than an
individual attribute placed in the session.
===============================
But http://faq.javaranch.com/java/DeclaringListeners explains, Classes implementing interfaces other than HttpSessionBindingListener and HttpSessionActivationListener need to be declared in DD.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic