aspose file tools*
The moose likes JSP and the fly likes disable the back button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "disable the back button" Watch "disable the back button" New topic
Author

disable the back button

sanchit agarwal
Greenhorn

Joined: Jun 01, 2012
Posts: 1
hello friends this is my first question on java ranch. I am working on web based application (database on cloud) and i want to disable the back button when user click on log out button, means that if user clicks on log out button then he will not be able to go to the previous page. I am doing invalidate the session but when i click the back button then it take me on previous page,although i am not able to do anything on it but still its matter that why it take me on previous page. I just want to stay on current page can anyone help me out...
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

this topic discussed many times here. please read this
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

welcome to javaranch :)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

You can't reliable do this, and it's a good thing too. It's not your browser; don't mess with it. Read InterfaceDesignersRule1

What problem are you actually trying to solve? Disabling the back button won't solve it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 244

This link may help you http://www.javaworld.com/javaworld/jw-09-2004/jw-0927-logout.html?page=1 and i added a time column which will store time in milliseconds when user logged in. After logout try to compare the time. i am giving a sample code in jsp sorry it is not in JSTL it is a basic example.
include this in jsp and get it in servlet update the value in db. user loged out you are redirected to jsp page. now when he/she clicks back button, compare old time with this one.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

mallikarjun dontamsetti wrote:This link may help you http://www.javaworld.com/javaworld/jw-09-2004/jw-0927-logout.html?page=1 and i added a time column which will store time in milliseconds when user logged in. After logout try to compare the time. i am giving a sample code in jsp sorry it is not in JSTL it is a basic example.
include this in jsp and get it in servlet update the value in db. user loged out you are redirected to jsp page. now when he/she clicks back button, compare old time with this one.


this currentTimeMillis techniques for only the page which we go for was displayed using POST method. this techniques can be avoided if you use PRG technique[search JSP FAQ].

and if back button rendering page was display by GET , then 1.clear browser cache 2. validate user name on the page.
Manjunath Gajula
Greenhorn

Joined: Dec 21, 2011
Posts: 12
Hi Agarwal,
Why have you decided to disable BACK button? Are you facing any problem when user clicks on back button?
caushik conjetty sekhar
Greenhorn

Joined: Mar 03, 2009
Posts: 4
Manjunath Gajula wrote:Hi Agarwal,
Why have you decided to disable BACK button? Are you facing any problem when user clicks on back button?


Please give a solution..
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5019
    
    8

caushik conjetty sekhar wrote:Please give a solution..

There is none that directly addresses the Back button question. The answer, as stated many times before, is to not try to disable the user's back button. The problem you want to actually solve is probably figuring out a way for your application to gracefully and correctly handle resubmissions of stale requests.


Junilu - [How to Ask Questions] [How to Answer Questions]
 
jQuery in Action, 2nd edition
 
subject: disable the back button