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?
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.
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.
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.
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.
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
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.