• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt on HttpSessionBindingListener

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srinivasan,
Thanks.
With regards,
Padma apriya N.G.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!