Making a JSP page to expire.


Web tier: servlets, JSP, Web frameworks: Making a JSP page to expire.

  1. Making a JSP page to expire. (7 messages)

    How to make a JSP page expire.
    When a user click on the back button of the browser an expire message will appears.
  2. Making a JSP page to expire.[ Go to top ]

    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.

  3. Making a JSP page to expire.[ Go to top ]


    put the following lines as the first lines in your jsp, this will expire your jsp if you do back button

    <% response.setHeader("Pragma","no-cache");%>
    <% response.setHeader("Cache-Control","no-store");%>
    <% response.setDateHeader("Expires",-1);%>

    hope this helps
  4. Making a JSP page to expire.[ Go to top ]

    Thank you.
    It is working for some JSP pages and it does not work for others.
    Any thoughts.

  5. Making a JSP page to expire.[ Go to top ]

    The code posted only works successfully for a GET request, not a POST. That is probably why it isn't working for the others.

    Jason Weiss
    Internet Applications Division
    Sybase, Inc.
  6. Making a JSP page to expire.[ Go to top ]

    hi krishna
       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
  7. Hi krishna,
                  Could you help me to figure out a solution for the expiration of the jsp's when the user opts the
    1.Refresh Button
    4.Right Click on the Mouse and select back.

  8. 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