I have 4 jsp files, login.jsp index.jsp view.jsp logout.jsp.
When I login I create a session and pass in the username and password of the user.
I let him browse through index and view and I have a simple button in my navbar for the logout.
logout.jsp:
<%@ page language="java" contentType="text/html; charset=US-ASCII"
pageEncoding="US-ASCII"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="US-ASCII">
<title>Logout Page</title>
</head>
<body>
<h1>You have logged out of the system!</h1>
<a href="login.jsp">Back to the Login Page</a>
<%
session.invalidate(); // destroy session
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.
%>
</body>
</html>
In all of my .jsp files I have the following lines at the beginning:
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.
But if the user is in the logout.jsp webpage he can simply press the back button of the browser and go back to the previous page (either index.jsp or view.jsp).
However it correctly destroys the session but I don't want him to be able to go back.