This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Himai Minh
Ranch Hand
Posts: 1566
10
  • 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
Posts: 2985
218
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: 1566
10
  • 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
Posts: 2985
218
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
Boost this thread!