This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Login/Logout Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Login/Logout Problem" Watch "Login/Logout Problem" New topic

Login/Logout Problem

Arshad Cs

Joined: Sep 04, 2009
Posts: 3
I used a HTML page to accept username and password. The params are accepted by a servlet that checks them. If accepted, it redirects to servlet Home otherwise redirects to an errorpage.
On successful login the values are put in session so that it can be displayed in all other pages.

Now, the problem part. When logout is clicked, the user should logout ... i used session.invalidate() to do this.... and then redirect to login page again.......but if i click the Back button in browser. . . it works as usual

Please suggest something

Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

Hi Arshad,

welcome to Java Ranch

your session is already invalidated. But when you click on back it shows last page you access, means at that page you are not check for session. So make always check for session, if session available or not. If session available process for further otherwise redirect to login page.

Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Arshad Cs

Joined: Sep 04, 2009
Posts: 3
Thanks for prompt reply....

is that any method to clear history... so that the "back" button doesn't work at all ?
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

Read below link..

Clear History If User Click Back Button

This topic already discuss with Java ranch...
srinivas srinivasmeenavalli
Ranch Hand

Joined: Jul 13, 2008
Posts: 65
Refer this
Arshad Cs

Joined: Sep 04, 2009
Posts: 3
I used the following code.... username and password are both checked to be admin/admin

Please correct me where i get wrong
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60740

"Arshad Cs", please check your private messages for an important administrative matter.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Login/Logout Problem
Similar Threads
automatic forward to URL after j_security_check
why Internet Explorer is different than other browsers in jsp?
session validate is not working in internet explorer
Invalidating session in a jsp
login and status error 400