Declaring Listeners (Wiki forum at Coderanch) (original) (raw)

Many ranchers seem confused about which listeners to declare in web.xml.

The main point is :
Classes implementing interfaces other than HttpSessionBindingListener and HttpSessionActivationListener need to be declared in DD.

A trick to remember which listeners to register in the deployment descriptor: Listeners can be classified in 2 categories:

We create the instances of these listeners and set them as attributes in specific http sessions.

The first type of listeners are configured in the deployment descriptor - as their methods are ALWAYS called when the event occurs.

The second type of listeners are not configured in the deployment descriptor.

Note: The HFSJ book is in error on this matter, as the errata has confirmed.


ServletsFaq