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

Sessions

 
Amandeep Singh
Ranch Hand
Posts: 850
  • 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...
 
Kunal Jag
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: 850
  • 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?
 
Irina Goble
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: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh thanks Goble for the reply...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic