• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to end a session  RSS feed

 
S.R.K.Vivek Raju
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have enabled session on login , i am using the hidden HTML session.
I have a link on every page saying logout, when i click on logout it returns back to the login page.

I want to know how can i end the session on clicking logout.
How would i do it since there is no special logout page.

Thanks in advance

With Regards
S.R.K.Vivek Raju.
 
Vishal Pai
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try session.invalidate()
 
S.R.K.Vivek Raju
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishal

Thanks for your reply,

I wanted to know how can we activate the method session.invalidate() by clicking on logout link.

How would i invoke an action by clicking on a link.

Thanks in anticipation

With Regards
S.R.K.Vivek Raju.
 
sandip mense
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek,

When u click on logout, pass a event (parameter) to the server, when ur controller (if you are using MVC) detects the logout event, it invalidates the session and forwards the suer to login page.
U bascially need to do a check of the event, if event is logout, process for invalidation.

Sandip
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sandip,

JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

thanks,
bear
JSP Forum Bartender
 
Vishal Pai
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to submit to either the same JSP or a Servlet or any form of Controller upon clicking on this link and then call the invalidate() method on the User's session object.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!