This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Listener question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Listener question" Watch "Listener question" New topic
Author

Listener question

sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
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


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Fraund Bei
Greenhorn

Joined: Feb 28, 2005
Posts: 11
yes,u should,as far as i know,the only listener u don't declared in DD is HttpSessionBindingListener

am i right?
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
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!


“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
Praveen Kumar Mathaley
Ranch Hand

Joined: Apr 14, 2003
Posts: 45
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

Joined: May 24, 2004
Posts: 783
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

Joined: Apr 14, 2003
Posts: 45
HttpSessionActivationListener should'nt be declared in DD..
please refer the link Listener in DD
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
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.
sairam sam
Greenhorn

Joined: Apr 15, 2005
Posts: 10
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Listener question
 
Similar Threads
Valentine's Ideas - Who's doing what?
How Big?
What is the need for a pattern like factory Pattern?
instructional video about twitter
PMP - Resource management