views:

91

answers:

2

I am having a session variable whose value can be changed from java and from Jsp as well. Is it possible to detect when this variable's value is changed?

+1  A: 

Use an HttpSessionAttributeListener.

+2  A: 

You can implement the HttpSessionAttributeListener and you will get notification every time the value is replaced. Notice that in the following cases (which is highly not recommended) it won't work:

MyObject myobj = (MyObject)session.getAttribute("obj");
myobj.setValue(newValue);
David Rabinowitz