Hi all, i couldn't understand event notifications clearly regarding valueBound & valueUnbound events. if there is a toy object that implements HttpSessionBindingListener interface if its bound to session attribute for example. if i execute below lines Toy toy = new Toy();
why valueUnbound() event is called please explain.
Thank you Mike.
posted 12 years ago
I ran the same test below and this is the output. It looks like this is what's happening. When setAttribute() is called a second time for the attribute "breed" Tomcat is simply doing some internal cleanup and removing the original object bound to the "breed" attribute and setting to null. This internal cleanup is causing an HttpSessionBindingEvent for valueUnbound() to occur.
(My code) HttpSession session = request.getSession(); Dog dog = new Dog("Airedale"); session.setAttribute("breed", dog); session.setAttribute("breed", dog);