Forums Register Login

Doubt on HttpSessionBindingListener

+Pie Number of slices to send: Send
Hi,
Can you please throw light on this point with regards to HttpSessionBindingListener.

The valueBound() method is called BEFORE the object becomes accessible through HttpSession.getAttribute()

Thanks in advance.
Padma priya N.G.
+Pie Number of slices to send: Send
Padma priya,


Specifiaction

setAttribute
public void setAttribute(java.lang.String name,
java.lang.Object value)Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.
After this method executes, and

1. if the new object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound. The container then notifies any HttpSessionAttributeListeners in the web application.

2. If an object was already bound to this session of this name that implements HttpSessionBindingListener, its HttpSessionBindingListener.valueUnbound method is called.

3. If the value passed in is null, this has the same effect as calling removeAttribute().


Parameters:
name - the name to which the object is bound; cannot be null
value - the object to be bound
Throws:
IllegalStateException - if this method is called on an invalidated session


Example :
1.session.setAttribute("myDog",new Dog("tomy"));
-- Containder after executing setAttribute it will do an additional job of notifying Dog class's listeners(HttpBinding Listener, HttpAttributeListener)(if any).

This listener notification should get finished before getAttribute is called thats the intent of your line posted.

2.session.getAttrinute("myDog");


[ August 17, 2007: Message edited by: Srinivasan thoyyeti ]
+Pie Number of slices to send: Send
Hi Srinivasan,
Thanks.
With regards,
Padma apriya N.G.
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 535 times.
Similar Threads
In ListenerClass
How to prevent duplicate logins
any listener on Sessions expiry
about HttpSessionActivationListner
perform a specific task on logout/closing of browser
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:48:59.