Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Foreman
Posts: 1898
12
  • 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.
 
Creator of Enthuware JWS+ V6
Posts: 3343
303
Android Eclipse IDE Chrome
  • 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 Foreman
Posts: 1898
12
  • 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
Posts: 3343
303
Android Eclipse IDE Chrome
  • 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:

 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic