File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Expiring session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Expiring session" Watch "Expiring session" New topic

Expiring session

Ganesh Gawande

Joined: Nov 06, 2008
Posts: 5
Please Can any1 help me for...
deactivation of back button of browser ....when I click my JSP page...

or session should expire when I clicked back Button of browser...

Its my kind request...I am not getting solution for this...


Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

You cannot disable the back button.

You can set all pages to no-cache and then not repaint them if the session is invalid (after the user signed out)

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Ankit Garg

Joined: Aug 03, 2008
Posts: 9466

I found a trick to disable the back button somewhere some time ago. But it was a very bad trick but still I would like to mention it. In that you open the new page in a new window or tab and then close the current tab or window using javascript. I know this is very weird but well it is a solution

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You should not change the client environment and the default user experience. Period.

Just code your application well.
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
You can consider, disabling the caching of a page in the browser. For doing so, see this:
Once this is done, any back button would result in the page being fetched from the server, and in the server you can handle your requirement, like invalidating the session(if it exists) and creating a new one.

Thanks and Regards
I agree. Here's the link:
subject: Expiring session
It's not a secret anymore!