• Post Reply Bookmark Topic Watch Topic
  • New Topic

Invalidate session from client side?

 
Himani Vashistha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As HTTPSession is a server side object, calling invalidate() method requires a call to the server. If my logout link is a simple html link, is ther anyway that I logout from the application/invalidate the session?

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to submit a request to the server to activate code to invalidate the session. It can be via a link, a form submit, an Ajax call, a frame, or any of the other request methods, but it has to be done on the server.
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just elaborating Bear's answer. You can call a JS function on your link. Have a FORM tag in your HTML whose action should be your servlet. In this function do a FORM_NAME.submit(). This will invoke your servlet, now you can invalidate session happily


Thanks
Abhishek.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That does not necessarily have to be a form. A plain vanilla link can also perfectly point to some servlet.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, use Ajax to do it behind the scenes without a page refresh if appropriate.
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:That does not necessarily have to be a form. A plain vanilla link can also perfectly point to some servlet.


That's right Bauke! Form is not needed. Thanks for correcting.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!