This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Listener configuration  RSS feed

 
Kedar Dravid
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While going through the Enthuware mock exams, came across a question on Listeners.
How would you register a ServletContextListener so that it receives appropriate notifications?
Answer: Configure it in web.xml

In the explanation of the answer to the question, it states:

All the following listeners have to be configured in web.xml:
ServletContextListener, ServletContextAttributeListener, HttpSessionAttributeListener and HttpSessionListener.

Does this mean that the other 4 types of listeners need not be configured in web.xml?
 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of all the listeners, only the HttpSessionBindingListener and HttpSessionActivationListener don't have to be registered with the DD.

correct me if i'm wrong....
 
John Wolf
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Minu,

You are right. Out of the eight listeners, only 6 of them are defined in the deployment descriptor (web.xml): -

1) ServletContextListener
2) ServletRequestListener
3) HttpSessionListener
4) ServletContextAttributeListener
5) ServletRequestAttributeListener
6) HttpSessionAttributeListener

and the two you mentioned are not defined in the web.xml since these are implemented by attributes.

7) HttpSessionBindingListener
8) HttpSessionActivationListener
 
Sanjay pts
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think
We have to register sessionActivationListenere Too.

Please update me

Thanx
sanjay
 
Radmika Arunachalam
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot find details in servlet2.4 spec. But in the below document it is said HttpSessionActivationListener also not required to declare in web.xml..

http://java.boot.by/wcd-guide/ch04s03.html

Anybody tested this and will it give error if you declare in web.xml? or just ignore it?..

Radmika
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!