Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is session id from cookie?

 
Ranjani Theyagarajan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Chittaranjan
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

isRequestedSessionIdFromCookie();


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.
 
P Chittaranjan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
option 3 and 4 are the right choices.
 
Satish Ramasamy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic