File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ Mock Exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ Mock Exam " Watch "HFSJ Mock Exam " New topic

HFSJ Mock Exam

Ashu Jain
Ranch Hand

Joined: Feb 24, 2008
Posts: 73
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 and why getServletContext servives. Trying to access this should give null pinter exception or illegalStateException.

Please clarufy this doubt
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115

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

I agree. Here's the link:
subject: HFSJ Mock Exam
jQuery in Action, 3rd edition