After the user logs out, if the back button on the browser is clicked, the web application will not be able to properly protect the protected page - after the Session is destroyed (the user logs out), the protected JSP page is displayed again in the browser. However, if the user clicks any link on the return page, the web application will jump to the login page and prompt that the session has ended. Please log in. The root of the above problem is that most browsers have a back button. When you click the back button, by default the browser does not re-fetch the page from the web server, but instead loads the page from the browser cache. Java-based Web applications do not limit this function, and this problem also exists in Web applications based on PHP, ASP and .NET. Fortunately, the HTTP headers "Expires" and "Cache-Control" provide a mechanism for application servers to control caching on browsers and proxy servers. The HTTP header Expires tells the proxy server when its cached page will expire. The newly defined header information Cache-Control in the HTTP1.1 specification can notify the browser not to cache any pages. When you click the back button, the browser re-accesses the server to fetch the page. Here is the basic method of using Cache-Control: 1) no-cache: Force cache to get new pages from the server 2) no-store: Do not store any pages in the cache under any circumstances To be on the safe side, it is best to add some settings to both the html page and the jsp For HTML pages, add: Copy code The code is as follows:<meta HTTP-EQUIV="pragma" CONTENT="no-cache"> <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> <meta HTTP-EQUIV="expires" CONTENT="0"> For JSP pages, add: Copy code The code is as follows:<% response.setHeader("Cache-Control","no-store"); response.setHeader("Pragrma","no-cache"); response.setDateHeader("Expires",0); %> That's it. |
<<: Detailed explanation of AWS free server application and network proxy setup tutorial
<br />Hello everyone! It’s my honor to chat ...
The final result is like this, isn’t it cute… PS:...
Table of contents 1. Introduction 2. Interface 3....
I am going to review Java these two days, so I wr...
This article example shares the specific code of ...
1 Introduction PostgreSQL is a free software obje...
background This bug was caused by滾動條占據空間. I check...
When using CSS pseudo-elements to control element...
background During development, we may need some s...
The mysql explain command is used to show how MyS...
Table of contents Overview 1. Overview of input a...
Table of contents 1.0 Introduction 2.0 Docker Ins...
Serve: # chkconfig --list List all system service...
This article describes the VMware virtual machine...
1. Arrange CSS in alphabetical order Not in alphab...