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.