• 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 question

 
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Can someone please telll me that do we need to declare the HttpSessionActivationListener in the deployment descriptor. According to H&F we need to specifiy the the DD but I think its wrong.

Thanks.

Sawan
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes,u should,as far as i know,the only listener u don't declared in DD is HttpSessionBindingListener

am i right?
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's correct. The only listener you do not have to declare in the DD is the HttpSessionBindingListener.

Also, frankflysky java, you may want to change your name to abide by the JavaRanch Naming Policy before you attract the attention of a bartender!
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpSessionActivationListener should not be declared in the Deployment Descriptor.

as the container will call appropriate methods on the session attributes implementing the HttpSessionActivationListener on migration...

so conclusion is HttpSessionBindingListener & HttpSessionActivationListener
should'nt be declared in the DD.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following is from HFS&J, page 254: (emphasis mine)

You do NOT configure session binding listeners in the DD! If an attribute class (like the Dog class here) implements the HttpSessionBindingListener, the Container calls the event handling callbacks (valueBound() and valueUnbound()) when an instance of this class is added to or removed from a session. That's it. It just works. But this is NOT true for the other session related listeners on the previous page. HttpSessionListener, HttoSessionAttributeListener, and HttpSessionActivationListener must be registered inthe DD, since they're related to the session itself, rather than an individual attribute placed in the session.

I can understand the confusion regarding these two, especially if you read HF, because on page 182 it is vague as to whether or not HttpSessionActivationListener is implemented as its own listener class (like HttpSessionAttributeListener is) or implemented as an attribute class (like HttpSessionBindingListener is). My understand is that it is implemented as its own listener class, and therefore must be declared in the DD. I welcome comments from anyone who is more familiar with the interface, or perhapse had the time to write some test code.
 
Praveen Kumar Mathaley
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpSessionActivationListener should'nt be declared in DD..
please refer the link Listener in DD
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the link Praveen. I appears that this is a common topic of discussion in this forum. I did a quick search and found 20+ topics regarding HttpSessionActivationListener dating back to 2001! Both the Specs and the HF book are rather vague in this matter, which I suppose is leading to much of the confusion out there.

So just so we are straight, HttpSessionBindingListener and HttpSessionActivationListener are both implemented as attribtues, and DO NOT need to be declared in the DD.

I appreciate the correction.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Important question....so remember
only HttpSessionActivationListener and HttpSessionBindingListener are not configured in web.xml....and ther rest of listener should be configured in web.xml....


Sai.
SCJP 1.4
SCWCD 1.4
 
reply
    Bookmark Topic Watch Topic
  • New Topic