XML & Web services: How to avoid user viewing the previous pages?
- Posted by: Edmond Hung
- Posted on: December 19 2002 07:17 EST
In my application, the user can make update in some pages and I want to avoid the user going back to the update page after the update has succeed. I have seen that some website can display a "Warning Page has been expired" on the browser when I try to go to the previous page. Can anyone please how to achieve it?
Thank you !!
- How to avoid user viewing the previous pages? by Web Master on December 19 2002 07:50 EST
- How to avoid user viewing the previous pages? by Brian OByrne on December 19 2002 16:38 EST
- How to avoid user viewing the previous pages? by Dave Hewitt on December 23 2002 05:24 EST
- This does not work in all cases by Parag Parashar on November 30 2004 00:21 EST
Stick this in your JSP page:
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
You could use a workflow-aware framework for your application.
JStateMachine (http://www.jstatemachine.org) is a good open source application framework that will help you deploy code on the server to ensure the flow you want is followed properly.
Setting expires and no-cache headings depends upon the browser behaving as it should...
Setting expires and no-cache headings depends upon the >>browser behaving as it should...
So, how does it achieve it? Because the data is on the browser how can you prevent user pressing the "Backspace" which will go to the previous page in IE.
You cannot prevent the user from pressing backspace or the back button.
What you can do is detect when the user has gone backwards and do something about it.
As Ferhart said, it makes it possible to detect when the user has used the back button and handle it easily.
For example: you could configure the workflow such that if an event arrived out of sequence the user would be brought to a page telling them that the back button shoud not be used, and given the option of starting the process again or continuing from where they left off.
Use POST for navigation. When a page is returned as a result of a form POST submission, browsers will refuse to display it unless the original data is re-posted, and will prompt the user with a 'page has expired' message if they hit the 'back' button.
We have included the code for page expiry, however we observe that it works in some cases and it does not work in some cases. Also is this code browser dependent.
Your feedback is highly apprecited.