Originally posted by Amandeep Singh: now the question is So what thing decides that HttpSessionListener cannot be declared in the web.xml?
Whatever thing it is, it is not correct. A class implementing HttpSessionListener must be configured in web.xml. You must be confusing it with HttpSessionBindingListener. From the Servlet spec SRV.15.1.7:
When an application stores an object in or removes an object from a session, the session checks whether the object implements HttpSessionBindingListener . If it does, the servlet notifies the object that it has been bound to or unbound from the session.
So there is no need to configure it in the deployment descriptor. [ August 02, 2008: Message edited by: Irina Goble ]