Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

controlling the browser's back & forward buttons  RSS feed

 
Shaik Vali
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , I have a problem

In my project once the admin logged in he can manipulate the normal users data, then admin will logout , agin if the normal user logged if we press the browser's back or forward button the normal user can see the admin's details which shoul not. Please give ths solution to controll the browsre's back & forward button
Note: I need to controll more than one page it should be better if is generic , I am using JSP, with Struts 2.0


Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't control the browsers navigation controls but there are ways to make sure your app handles these events gracefully.

Look in the JSP FAQ for tips on setting the no-cache headers and the Post-Redirect-Get pattern.
 
mnadeem chishti
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you can control the browser back and forword buttons from your code. But you can hide bar completely while opening the browser window using javascript function window.open(.......).
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by mnadeem chishti:
yes you can control the browser back and forword buttons from your code

No. You cannot.
 
Qussay Najjar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben you're 100% right, you can't I've racked my head before searching for it but couldn't, but I've solved this problem as following..
I had two pages (signIn.jsp) and (account.jsp).
so after the user sign in perfectly he's forwarded to account.jsp
what causes the problem is that the user doesn't click on (sign out) link to invalidate his session, and instead he just clicks back button and the session is still alive..
so I've added

just at the very end of my (signIn.jsp) and the problem is solved...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Qussay Najjar:
...just at the very end of my (signIn.jsp) and the problem is solved...

This will, of course, only be effective if the user backs up all the way to the sign-in page. If they've clicked hundreds of links into the app, this is unlikely. And while this may invalidate the session, it does nothing to prevent cached pages.

Using the patterns that Ben mentioned is the best way to deal with these issues.
[ February 07, 2008: Message edited by: Bear Bibeault ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!