• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Why session IllegalStateException?  RSS feed

 
Ranch Hand
Posts: 1931
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Why the response wrapper? Just use a straight-forward servlet filter.



Articles I read said the response may already be configured and the setting not incorporated if not do this way.

Can you answer another question for me? If I am checking for session = null how do I still get an IllegalStateException on the line session.invalidate()?

 
Marshal
Posts: 67255
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The docs for HttpSession explain when an IllegalStateException will occur.
 
Bartender
Posts: 20566
120
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In practical terms, what probably happened was that you've committed the servlet response and then attempted to destroy the session.

The session ID is going to have been sent as part of the response if you used cookies or URL rewriting, and here you are deleting that session out from under it. If the server hadn't thumped you, the client would have, because the next request would be trying to locate a non-existent object using that session id (jsessionid).
 
Rancher
Posts: 3985
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep.
That code forwards to a JSP, which will send the response to the client.
When that returns back to the above servlet it's well past the point you can be messing around with the session.
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!