• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to restrict going back in jsp?

 
kiran madhan
Ranch Hand
Posts: 30
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a problem in my jsp application....that after I logout from panel in my application.....still i am able going back without login but by pressing back button....!
I did not understand how to restrict it...can anybody help me in this...?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
410
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kiran,
Why do you need to disable the back button? If the user tries to perform an action, his/her session is invalid. And if this is about seeing the data after logout, the user needs to close the browser anyway.
 
Stefan Evans
Bartender
Posts: 1822
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presumably the user sees the pages retrieved from the cache - rather than being requested again.

So one solution would be to tell the browser not to cache these pages and go to the server every time.

Check out the FAQ page:  http://www.coderanch.com/t/659993/Wiki/Cache-Headers
 
Matt Keller
Ranch Hand
Posts: 32
1
Eclipse IDE Java jQuery
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can learn a lot from how the SPA frameworks like WebRocketX and Angular handle this.  They use the browsers behavior of navigating within anchors in the page as a way of "tricking" the browser not to leave a page when the back button is clicked.  When you enter your page you need to modify the address by putting a hash (the # symbol), this will cause a hash change event which at this point you ignore.  You probably want to use a hash like "#nav=welcomepage"  Later when the user presses the back button on your welcome page the browser will think its just stepping back an anchor.  Your javascript can watch for this hashchange event and programmatically click the  forward button to counteract the back.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!