Meaningless Drivel is fun!
The moose likes JSP and the fly likes Logging out problem in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Logging out problem in JSP" Watch "Logging out problem in JSP" New topic

Logging out problem in JSP

seema mani
Ranch Hand

Joined: Sep 30, 2001
Posts: 49
I'm using session.invalidate to logout from the session. After that I'm redirecting the user to the login page again. The problem I'm facing is that if the user clicks the back button of the browser, he's able to see the previous page details again. How do I prevent this ? If the user clicks back button after logging out he should get the message 'You are not logged in'.
How do I achieve this ?
PLease help.

Sun Certified Java Programmer<br />Sun Certified Web Component Developer<br />Sun Certified Business Component Developer
Po-yu Chien
Ranch Hand

Joined: Nov 01, 2001
Posts: 45
I don`t know how actually solve your problem,
however this problem should be related with browser`s cache mechanism. There should be some <meta .../> tag to disable both browser`s cache and proxy`s cache. This should be the direction toward solving the problem. Good luck!
Sals Hamid

Joined: Jan 04, 2002
Posts: 24
By using if condition u can do this e.g.
<jsp:forward page ="login.html"/>

No Path of Flowers lead to glory
Biju Nair
Ranch Hand

Joined: Dec 15, 2001
Posts: 31
Checking for the session value on the server side may not help as when u press the browser's back button, the page is displayed from the browser's cache. One way to prevent this is to avoid caching of the page by the browser as well as any proxy servers (if any).
Try this code in all your jsp pages which you don't want to be cached
For more information about tag-libs to prevent caching, go to
[ January 27, 2002: Message edited by: Biju Nair ]

--: Biju Nair :--
seema mani
Ranch Hand

Joined: Sep 30, 2001
Posts: 49
Thanks Biju
That worked just fine.
By the way, just wanted to mention that I'm also from TVPM,Kerala.
Thanks a lot.
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
plz use this space for technical query rather then personal touch. You can make use of email faculty for the same.
Don't mistake. Let's make friends with all, rather then region specific.

Sharing is learning
Doshi Milan
Ranch Hand

Joined: May 29, 2001
Posts: 112
Hello friends,
I am working on a huge project which have n number of JSPs and Servlets (going well over hundreds ). In our maintainance work we ahave been told about the similar probelem. i.e when the user logs out he should not be able to view his earlier pages using the browser Back button.
I know pragma \no-cache etc could have worked had it been in each and every JSP \ Servlet.But its not there and it is not feasable to change so many servlets \ JSPs
NOW !!! What can be done.
How do we clear the Browser history on Log out so that earlier pages are not seen.
Thanks in advance,
Milan Doshi
I agree. Here's the link:
subject: Logging out problem in JSP
It's not a secret anymore!