• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session listeners doubt

 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
All of the listener classes are to be specified in web.xml. At lest, that's what I though until I read some materials on HttpSessionActivationListener and HttpSessionBindingListener. I read that both of these can be implemented by session attributes, and they are notified automatically by the container on every instance that implements it. Does this mean I can both specify them in the DD, and also implement it in arbitrary attributes?
Thanks.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 4 different listeners to session events. 2 Have to be defined in web.xml and the other 2 by objects stored in the session.

HttpSessionListener:
  • Listens for sessions being created and destroyed
  • Must be defined in the DD

  • HttpSessionAttributeListener:
  • Listens for attributes being added/removed from the session
  • Must be defined in the DD

  • HttpSessionBindingListener:
  • Listens for when the Bound object is added or removed from the session
  • Must be implemented by the Bound object (not defined in the DD)

  • HttpSessionActivationListener:
  • Listens for the session an object is Bound to being activated/passivated
  • Must be implemented by the Bound object (not defined in the DD)


  • When people generally refer to 'session listeners' they are usually referring to the HttpSessionListener, which has to be defined in web.xml.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!