Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EPractice Lab review exam 1 : about valueUnbound() is called after the getAttribute of HttpSession?

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The valueUnbound method must be called ____ the object is no longer available via the getAttribute method of the HttpSession interface.
a. before
b. after
Given answer: after


I think the valueUnbound method (of HttpSessionBindingListener) is called after the removeAttribute of the HttpSession or the invalidate() of HttpSession.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2535
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer given by the mock is correct.

From the Servlet 3.0 specs:
7.4 Binding Attributes into a Session
The valueUnbound method must be called after the object is no longer available via the getAttribute method of the HttpSession interface.
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Frits, thanks for your reply.
But it does not make sense to me when it says "when the object is no longer available via getAttribute..."
I tried this:



Output from the servlet:

Bound the attribute: Dog : com.nullhaus.Dog@28c540
Add the attribute og:com.nullhaus.Dog@28c540
Remvoing the dog:
Unbound the attribute : Dog : com.nullhaus.Dog@28c540
remove the attribute og:com.nullhaus.Dog@28c540
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2535
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can test this part of the specs by trying to get the attribute from the HttpSession inside the valueUnbound method, like:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic