• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listener configure in DD

 
gunjan deogam
Greenhorn
Posts: 11
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please can any one clear me which listener are configure in DD and which are not?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2452
97
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gunjan,

In the web.xml:
ServletRequestListener
ServletRequestAttributeListener
HttpSessionListener
HttpSessionAttributeListener
ServletContextListener
ServletContextAttributeListener

and not in the web.xml
HttpSessionBindingListener
HttpSessionActivationListener

Regards,
Frits
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpSessionActivationListener is also configurable in the DD. You can configure it in the DD if you want to listen for when a session migrates to another VM. It can also be implemented by a session attribute class to prepare the attribute for the migration.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2452
97
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,

I don't think that is correct. According to the book of Sun Certified Web Component Developer Study Guide (by David Bridgewater) it is not like that:
Chapter 4:
Now we move on to two other session-related listeners which are different in character
to the listeners we have previously encountered, whether on session, request, or
context. These listeners are:
HttpSessionBindingListener
HttpSessionActivationListener
Classes implementing these listener interfaces are not declared in the deployment
descriptor. They become known to the web container through a different mechanism
entirely.

I checked the servlet 2.4 specs and it also confirms this

SRV.15.1.8 HttpSessionActivationListener
Objects that are bound to a session may listen to container events notifying them
that sessions will be passivated and that session will be activated. A container that
migrates session between VMs or persists sessions is required to notify all
attributes bound to sessions implementing HttpSessionActivationListener.

because they don't mention the phrase:
To receive notification events, the implementation
class must be configured in the deployment descriptor for the web application

or did I miss something?
Regards,
Frits
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frits,

I'm reading the Head First Servlets and JSP book and it says that it can go both ways. It says that it's used when

You want to know when a session attribute has been added, removed, or replaced (p.182).


and also when

You want to know when a session moves from one VM to another (p.264).


In an exercise (p.264), it asks the reader to mark whether the listener is used on an attribute class or defined in the DD and HttpSessionActivationListener has checkmarks next to both. But I've never written a distributed Java web app, so I don't know for sure.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this FAQ.
 
gunjan deogam
Greenhorn
Posts: 11
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all of you. But I read that HttpSessionActivationListener configure in DD.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gunjan deogam wrote:Thanks all of you. But I read that HttpSessionActivationListener configure in DD.

Where ?
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The FAQ that Christophe referred to says that the Head First Servlets and JSP book has an error concerning this, so this is probably what I saw.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic