• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSessionBindingListner

 
Sanjay pts
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which method will get call when i do this

session.getAttribute();
session.setAttribute();
session.removeAttribute();


from HttpSessionBindingListner class

public void valueBound()
public void valueUnbound()




i think for

session.setAttribute() ->vauleBound()
session.removeAttribute()->valueUnbound()
session.getAttribut()->???




Thanx
sanjay
[ June 12, 2005: Message edited by: Sanjay pts ]
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sanjay ,

Assuming you are talking of a specific class object , which is added or removed from the session ie when

session.setAttribute("dog",dog);
session.removeAttribute("dog");
session.getAttribute("dog");

In the first case the valueBound as specified by you .
In the second case valueUnbound.
In the 3rd case none of the events are called since it does not involve any modification in the session or the object class (Dog)

Also in the first case attributeAdded of HttpSessionAttributeListener is called
In the second case attributeRemoved of HttpSessionAttributeListener is called
And if we do session.setAttribute("dog",newDog);
then attributeReplaced method is called

So in the first two case two methods are called

Hope this helps

Thanks
Shiva
 
Radmika Arunachalam
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also in the first case

setAttribute(key, object) - if the key already exists in the session, container calls valueUnbound of the old object first, then valueBound of the new object.. Let me know if this is wrong..

Radmika
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic