Web tier: servlets, JSP, Web frameworks: Making a JSP page to expire.
How to make a JSP page expire.
- Posted by: Saad Hamdan
- Posted on: January 23 2001 15:41 EST
When a user click on the back button of the browser an expire message will appears.
- Making a JSP page to expire. by Tyler Jewell on January 23 2001 16:26 EST
- Making a JSP page to expire. by Krishna Muthyala on January 24 2001 10:44 EST
- Making a JSP page to expire when the user refreshes. by Karthic Gunasekaran on December 07 2004 00:40 EST
- Making a JSP page to expire when the user refreshes. by Shiva hari kumar Balasubramanian on October 10 2013 08:21 EDT
This is a very complicated issue to consider.
It's not just the back button the browser but the Refresh or Stop buttons, too.
Generally, this is what I do (I could go on for pages about this, but will keep it short here).
Every page can pass in a query string parameter called TXID. When a JSP page first runs, generate a random number and store that number in a linked list as part of the HttpSession object. The TXID is sent as part of the outgoing page and made to be returned on all links and form invocations. When the user clicks on a link, the TXID will be returned to the JSP.
The first thing the JSP does is to generate a new TXID and append it to the linked list. Then take the TXID that was returned from teh browser and make sure it is the second to the last item on the linked list (the last item will be the new TXID that you just put on there). If the TXID that you have is not the second from the last one on the linked list, then you know that the user has refreshed a stale screen, hit the back button, or some other variation.
put the following lines as the first lines in your jsp, this will expire your jsp if you do back button
hope this helps
It is working for some JSP pages and it does not work for others.
The code posted only works successfully for a GET request, not a POST. That is probably why it isn't working for the others.
Internet Applications Division
We used your code and it is working fine in my pages ..before that i faced problem when i go by browser back button and the page was not refreshing...Thanks for ur helpful code ..
by Harikrishna and Smitin
Could you help me to figure out a solution for the expiration of the jsp's when the user opts the
4.Right Click on the Mouse and select back.
You simple use the above metioned response.header... for client end and have a logout attritube in session for server side validation.
Or you can leave the client browser and have a dedicated table in your Database with just 2 columns, like create table session_table(session_id varchar, logout_flag varchar). Now everytime logout is pressed get the session id and store if with Y as logout_flag. so if client browser supplies old credentials you can find & ground it then ask for new login credentials