my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes valueUnbound method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "valueUnbound method" Watch "valueUnbound method" New topic
Author

valueUnbound method

deepa raj
Ranch Hand

Joined: Jul 25, 2008
Posts: 124
please list the scenarios of the HttpSessionBindingListener.valueUnbound method will be called.

like

1. When the session about to time out.
2.


While removing/replacing the attribute from the session , whether the unbound method will be called or not?


in the same way , when the session is about to timeout , removeAttribute() method should be called before the timeout right ??

somebody please clarify doubts.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi,


how far you try this ?
-----------------------------------------------
While removing the attribute from the session
------------------------------------------------
deepa raj
Ranch Hand

Joined: Jul 25, 2008
Posts: 124
i didnt try till now.

I just want to make sure my understanding in concepts. :-)
deepa raj
Ranch Hand

Joined: Jul 25, 2008
Posts: 124
Thought of sharing you the information :

When session was created


When the Dog Object Added to the Session.


When the added Dog object has been reaplced with another Dog Object.


when the replaced Dog Object Removed from the Session


Again When the Dog Object Added to the Session.


While invalidating the session.


so while removing /replacing the attribute from the session (using setAttribute/removeAttribute) unBound method will be called.

but during sessiont timeout / invalidation , only the unbound method will be called. NOT attributeRemoved method.
[ August 11, 2008: Message edited by: deepa raj ]
Lakshmi Narayanan
Ranch Hand

Joined: Apr 29, 2008
Posts: 58
so while removing /replacing the attribute from the session (using setAttribute/removeAttribute) unBound method will be called

When we set the attribute only valueBound is called not valueUnbound. If i am wrong please correct me.
RemoveAttribute or replacing - valueUnbound and corresponding attributeRemoved/attributeReplaced is correct.

eg.,
When we call twice setAttribute I feel only valueBound is called.
setAttribute("javaranch", new com.javaranch());
setAttribute("javaranch", new com.javaranch());


Thanks<br />Lakshmi<br />SCJP 1.4 - 90%<br />SCWCD 5 - 89%
Lakshmi Narayanan
Ranch Hand

Joined: Apr 29, 2008
Posts: 58
While invalidating the session.

code:
--------------------------------------------------------------------------------

HttpSessionBindingListener.valueUnBoundHttpSessionListener.sessionDestroyed


What is the sequence on this
first valueUnbound and then sessionDestroyed right
 
Consider Paul's rocket mass heater.
 
subject: valueUnbound method