Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding Listeners

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • 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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi Christophe,
Thanks.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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!
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Amit Goyal
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic