• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listener configuration

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think
We have to register sessionActivationListenere Too.

Please update me

Thanx
sanjay
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic