• 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

regarding listeners

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
"If servlet context is destroyed all the attributes associated with it will be removed so the attributeRemoved() will be called for those attributes"
Is this statement true?

Thanks in advance,
Malini.
 
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
I can't find such a statement in the specification.
 
Nagamalini Pampati
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's no such statement in the specification but i have that doubt.....
to be more clear....
i have a class ABC implementing ServletContextAttributeListener......so when the context is destroyed will the attributes associated with it are rremoved from the context?if they are removed, is the attributeRemoved() of class ABC called?
Pls help me..
Thanks in advance,
Malini.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the listeneres will/must be notified.

Imagine your application is just a single part of big enterprise.
due to some reasons(maintennance) you deice to undeploy your application.
And you want release resources that you have acquired or you want to send a message to JMS server or anything....

You can say this can be done in ServletContextListener. But say your app doesnot have any of these listners. Then attribute listeners can help.

It lot depends on how beautifully we design our application.
 
Nagamalini Pampati
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Govinda Attal
 
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
I don't know what you base this kind of statement on.
As I said, there's nothing in the spec about this, so you'd better refer to the container's documentation.

I've just tried on Tomcat, and attributeRemoved was not called.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right Satou.

I tried on WSAD5.1 and got the similar result as told by you.
Further I tried same logic on Session.

My Conclusion: ServletContextListener and ServletContextAttributeListener interface are not related/dependent on each other, and a call to contextDestroyed() doesn't trigger call to attributeRemoved() method.
Similarly, a call to sessionDestroyed() doesn't trigger attributeRemoved() to be called.

I would be glad if anyone would correct/add to my understanding.

Thanks and regards,
Saurabh
 
Nagamalini Pampati
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but in HFSJ it is given as calling invalidate() on session object will unbind all session attributes currently stored in the session.doesn't this mean that valueUnbound or attributeRemoved methods are called?
Thanks and Regards,
malini
 
Saurabh Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
calling invalidate() unbounds the session attributes and notifies the object implementing HttpSessionBindingListener, and calls valueUnbound(). But invalidate() doesn't trigger attributeRemoved().

Please correct me if wrong.

Thanks and regards,
Saurabh
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic