Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session.invalidate

 
amit ang
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Can anyone help me?
I have implemented HttpSessionListener and have implemented the methods for Create and Destroy the session.
now when i hit the page with a browser i get the message from the Create method. But, when i close the browser i don't get the message from the Destroy method (I hope when you close the browser the session should be invalidated).
Any seggestions?
Thanks in Advance
Amit
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the session will not be invalidated when you close the browser. There is no way for the server to know when the browser closes. If the server tries to send a response then an exception will be thrown. You can use JavaScript to determine when the browser window is being closed and then meybe send a message to the backend to indicate that.
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm intersted to try it with destroy method.
But i have any knowledge with Javascript. Can your reply to write the code(Javascript) to do it ?
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic