• 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

Doubt regarding Listeners

 
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can anybody clarify as to why HttpSessionActivationListener and HttpSessionBindingListener are not listed in the DD?
With regards,
Padma priya N.G.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A little something about Declaring Listeners in the FAQ
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Christophe,
Thanks.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Padmapriya,

Also there was a nice discussion about the same with the mockexam question here .

Hope this will also help!
 
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Christophe

I think that's true, only and only if, the attribute classes by itself implements HttpSessionActivationListener.

However if you make a seperate class implementing this listener, which is possible too, you have to configure that in deployment descriptor. I think so.

Regards,
Khushhal
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mmmh, I'm not sure about this. As the API says, 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.. What's the point in registering such a listener in web.xml ? Only objects in the session implementing this interface will be notified.
 
khushhal yadav
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Christophe,

That's Ok. But see at the two classes below.
I am totally agree with you for the first class, we don't have to configure that in web.xml.
But what about second class??
Please let me know about that.

Class First




Class Second




Regards,
Khushhal
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it's not associated to any session object, I can't see why the container would call it. I persist to say that it's no use to register it, and that it won't be called The API also states that a container that migrates session between VMs or persists sessions is required to notify all attributes bound to sessions implementing HttpSessionActivationListener.. I'd like to try it though.
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

As far as these two listeners (HttpSessionActivationListener and HttpSessionBindingListener) are concerned, container can identify at runtime by using "instanceof" operator on attribute class which is going to associate with to session. So no need to specify in the web.xml.

But in case of other listeners, container has no information whether it exist or not in your web application so as you have to specify it in the web.xml.

Hope it will help!!!

Regards,

Amit Goyal
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic