Thanks Manikandan..!
That was a silly mistake on my part. I think I have been reading too much.
But here is some addition to the same problem.
Suppose class X implements the binding listener and in a servlet we have
req.getSession().setAttribute("key", new X());
req.getSession().setAttribute("key", new X());
req.getSession().setAttribute("key", "x");
req.getSession().removeAttribute("key");
Now, as far as I get it, when the 2nd object is added, the 1st one will be removed and its valueUnbound() will be called before the valueBound() of the 2nd element. So the order of listener method calls will be -
valueBound(), valueUnbound(), valueBound(), valueUnbound()
But the answer in the book doesn't confirm to this.
Tell me where am I going wrong.