This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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 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
Joined: Oct 04, 2006
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
Joined: Aug 21, 2006
calling invalidate() unbounds the session attributes and notifies the object implementing HttpSessionBindingListener, and calls valueUnbound(). But invalidate() doesn't trigger attributeRemoved().