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 is session id from cookie? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "is session id from cookie?" Watch "is session id from cookie?" New topic

is session id from cookie?

Ranjani Theyagarajan

Joined: Feb 08, 2006
Posts: 19
what will be returned by the method isRequestedSessionIdFromCookie(); if the session has been already invalidated?

will it throw illegalStateException or will it return false?

The spec is not talking about this...
P Chittaranjan
Ranch Hand

Joined: Feb 09, 2006
Posts: 47
Hi ,

If you are creating the session object, whether you invalidate it or not isRequestedSessionIdFromCookie will return true.
If you are not creating the HttpSession object, you will get false.

It will not throw any exception.


Thanks,<br />Chittaranjan<br />SCJP 5.0,SCWCD1.4,SCBCD 5
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026


is a HttpServletRequest method and NOT HttpSession method. So you don't have to worry whether the session has been invalidated or NOT.

I found a similar interesting question regarding HttpSession.

Which of the following methods will NOT cause an error if invoked after session has been invalidated.

1. getCreationTime()
2. isNew()
3. getServletContext()
4. setMaxInactiveInterval(int interval)

If you observe closely you can figure out option 3 would be the right choice.

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
P Chittaranjan
Ranch Hand

Joined: Feb 09, 2006
Posts: 47
option 3 and 4 are the right choices.
Satish Ramasamy

Joined: Feb 13, 2006
Posts: 15
You guys are scaring me.

I am reading HFSJ for the second time and I didn't come across this method isRequestedSessionIdFromCookie() in the book.

Please advice whether I should refer some other book also for the exam. I thought that this book would provide every detail to score 100%.

I do read the Specification but I don't concentrate on methods/details that are not there in HFSJ book, assuming they won't be asked in the exam. Please advice whether I am doing the correct thing for scoring 100%(only from the exam perspective, though I understand that scoring 100% doesn't mean that I know a to z in Servlets/JSP).

Thanks,<br />Satish<br /> <br />SCJP 1.4 - 98%
I agree. Here's the link:
subject: is session id from cookie?
It's not a secret anymore!