This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IllegalStateException in conjunction with HttpSession  RSS feed

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

why do most HttpSession methods like setAttribute(), getAttribute(), getAttributeNames(), removeAtrribute(), getCreationTime(), getLastAccessedTime(), invalidate(), isNew() declare an IllegalStateException in their throws clause and methods like getId(), getMaxInactiveInterval(), setMaxInactiveInerval() do not?
I mean if, the session has been invalidated before calling the latter category of methods, shouldn't there be an exception of this type as well?
What happens then, if I call HttpSession.getId() after the current session has been invalidated?

Kind Regards, Andy
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getID() and other methods that don't throw an Exception are sole getter methods which on top are not bound to the session's state.

invalidate(), getLastAccessedTime() and others are all methods that rely on the fact that the Session is still alive.
 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the API
it is clearly mentioned over there.......
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!