This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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!