Its not duplicate to this Prevent user from seeing previously visited secured page after logout . i have studied it to find out some thing useful. but it is irrelevant to my issue.if i disable java script on the browser, this duplicate ticket solutions will not work at all for me. Please suggest me so that i can make proper logout session. I Have tried so many logout codes but nothing is working on logout session. when i click on back , the it is going to be the normal session. my example code is ,
"logout link in menu:"
<a href="LogOut.do"><i class="fa fa-sign-out"></i><b> Logout</b></a>
"logout Servlet Code":
public class LogOutServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
HttpSession session=request.getSession();
String userName = (String) session.getAttribute("customerDetails");
if (null == userName) {
request.setAttribute("Error", "Session has ended. Please login.");
RequestDispatcher rd = request.getRequestDispatcher("logout.jsp");
rd.forward(request, response);
}
}
}
"logout.jsp"
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title>Logout</title>
</head>
<body>
<% session.invalidate(); %>
<p>You have been successfully logout</p>
</body>
</html>
I have tried it with many different code. but still when i click on back button of browser.it displays home page as normal.please help to find the best code for logout.