This week's book giveaway is in the Agile and Other Processes forum.We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!See this thread for details.

disable the back button

sushant prabhu

Ranch Hand

Posts: 66

posted 15 years ago

i hav developed a banking application using servlets - jdbc. when the account holder enters the servlet he gives his acc no and password on the basis of which he performs his deposit and withdrawal operations. i dont want subsequent users or the same user from the same browser to see the transactions he has done. how do igo about it

Sushant Prabhu<br />SCJP2<br />SCWCD<br />OCA9i

maha anna

Ranch Hand

Posts: 1467

posted 15 years ago

There is no way of doing it except make the browser not to make a cache of your page. Please make a search in this forum. This question came up many times before.

regds maha anna

Sean MacLean

author
Ranch Hand

Posts: 621

posted 15 years ago

You can set the header from the servlet before you write out anything to the client to effectivly remove any cached pages. response.setHeader("Cache-Control", "no-cache"); response.setHeader("Expires", "Thu, 01 Dec 1994 16:00:00 GMT"); This will not allow the use of the browser's back button (actually, you can use the back button all you want but you'll have to refresh to see any content). Sean

Mahajan Bhupendra

Ranch Hand

Posts: 118

posted 15 years ago

hi my friend anand has done a little trick and it works.. just add javascript lines to your code.

<script language="Javascript"> javascript:window.history.forward(1); </script> it's nothing but if user click on back button he will be forwarded to the current page only.. Bhupendra

<B>Bhupendra Mahajan</B>

octavyn pittman

Ranch Hand

Posts: 134

posted 15 years ago

Bhupender, Wouldn't this little trick just solve the above problem for only one click, but a user could then look at the back button's history list or even just click back twice and get around the trick? OP

Mahajan Bhupendra

Ranch Hand

Posts: 118

posted 15 years ago

yes of course it will work for only one back.. something is better than nothing don't u think so??? Bhupendra

<B>Bhupendra Mahajan</B>

maha anna

Ranch Hand

Posts: 1467

posted 15 years ago

Yes. We can make it harder for the user to go back but not impossible. regds maha anna