after logout click on back button cache issue

后端 未结 4 1293
梦谈多话
梦谈多话 2021-01-06 05:47
<%
    response.setHeader(\"Cache-Control\",\"no-cache,no-store,must-revalidate\");//HTTP 1.1
    response.setHeader(\"Pragma\",\"no-cache\"); //HTTP 1.0
    resp         


        
4条回答
  •  無奈伤痛
    2021-01-06 06:02

    Create a session attribute let's say "valid" and initialize it with any value other then null in the jsp, just after the login credentials were matched. Now create a verify.jsp with the following code:

    <%
    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
    response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
    if(session.getAttribute("valid")==null)
    {
        out.println("");
    }
    %>
    

    Now simply include this jsp file on each jsp page and its done. Do not forget to write "session.invalidate();" in logout.jsp

    Hope it will work..!!!

提交回复
热议问题