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

HFSJ Mock Exam

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going through HFSJ 1st edition Q15.

Q:- Once a session has been invalidated, which HttpSession methods can be called on that session without throwing illegalState Exception?

Options -

A: invalidate
B: getAttribute
C: setAttribute
D: getServletContext
E: getAttributeNames

Answer: - Since the servletContext survives, getServletContext can be called successfully on an invalid session.

I am not so clear why? if an object is invalid now...how and why getServletContext servives. Trying to access this should give null pinter exception or illegalStateException.

Please clarufy this doubt
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When you call invalidate()
The session ID no longer exists.
The attributes are removed from the session object.

Kathir
 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic