This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes Logout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Logout" Watch "Logout" New topic


Abhijit Ajansondkar

Joined: Jul 13, 2012
Posts: 10
hi I am Abhijit. I coded this small module which uses session. But i want the logout functionality. Thus i used invalidate() function . This is my code

The rest is working good, it is printing the name - value pair in the while loop
My main concern is how to write a code which is based on login-logout function . If somebody help me it is very good for me.
When I click logout link it is going to login page, but when i again click the back button of the browser, it is again going back to the previous page instead of redirecting to the same login page
so please help me
Pyla Rao
Ranch Hand

Joined: Jul 10, 2012
Posts: 50
For Log out functionality you need to kill the session using invalidate as follow

the below article is good example for login and logout.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 659

The OP is already doing session.invalidate(). When you click back, you see the logged in page back, it's most probably the cached page been shown by the browser. So, we need to restrict the browser caching.
Don't get me started about those stupid light bulbs.
subject: Logout
It's not a secret anymore!