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

Sessions

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which three interfaces need to be declared in the web application descriptor?


So far there are 4 listeners related to the sessions.
Only three listeners can be there in Web deployment descriptor.
So what thing decides that HttpSessionListener cannot be declared in
the web.xml?

Do advice...
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Which three interfaces need to be declared in the web application descriptor?



Following are the different event listeners which can be configured to be used in a Web application:

Servlet Context Events
javax.servlet.ServletContextListener
javax.servlet.ServletContextAttributeListener

To receive notification events, the listener implementation class must be configured in the DD.


Request Events
javax.servlet.ServletRequestListener
javax.servlet.ServletRequestAttributeListener

To receive notification events, the listener implementation class must be configured in the DD.

Session Events
javax.servlet.http.HttpSessionListener
javax.servlet.http.HttpSessionAttributeListener
javax.servlet.http.HttpSessionBindingListener
javax.servlet.http.HttpSessionActivationListener

There's no need to configure the HttpSessionActivationListener and HttpSessionBindingListener implementation classes in the DD.

Regards,
 
Amandeep Singh
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks jaggi for reply,,,but now the question is So what thing decides that HttpSessionListener cannot be declared in
the web.xml?
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
Amandeep Singh
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh thanks Goble for the reply...
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic