Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Foreman
Posts: 1922
13
  • 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: 3348
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: 1922
13
  • 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: 3348
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:

 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic