• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in valueBound() and valueUnbound()

 
swapna rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My doubt is when valueBound() method will be called?This method is called when ever an attribute is added to the session (If that attribute class implements HttpSessionBindingLister). Is it called before binding the attribute into the session or after binding into the session?If i use,Httpsession.getAtrribute("XX")in valueBound() will it be available?
Same doubt applies to valueUndound().please clarify it.
 
Ashok Kumar Babu
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Swapna,

The valueBound() method in HttpSessionBinding listener will be invoked before an instance of that implemented class binds to the Session.

If i use,Httpsession.getAtrribute("XX")in valueBound() will it be available?


No it wont be available, you will be getting a null.
 
Kumar Garlapati
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
valueBound() method will be called after setAttribute("","") is done.
so attribute values can't be available in valueBound()

it's reverse in the case of valueUnBound() method, if invalidate() method is called on a session, valueUnBound() method is fired and then after session gets invalidated. this will not fire if session expires(timeout).
 
Kumar Garlapati
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could any one please correct my statement, if i am wrong.
i confused.
 
swapna rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
valueBound() method will be called after setAttribute("","") is done.
so attribute values can't be available in valueBound()

This statement is wrong .valueBound() method will be called before setAttribute("","") is done and valueUndound() is called after removing the attribute from session.In both the cases , we cannot retrieve the attribute value inside these two methods.
Please anyone correct me,if I'm wrong.
 
Ashok Kumar Babu
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Swapna,

Your last statements are true.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic