Issue
<form method=“post” action=“mainServlet>
<button> Save<\button>
I want user to automatically logout after submitting form to main servlet. Servlet redirects to main page but if user clicks back button he can access the form again and I want to prevent that
Solution
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Cache-Control","no-store");
response.setDateHeader("Expires", 0);
response.setHeader("Pragma","no-cache");
%>
try adding this in form page at top also add a check using session.getattribute and if its null redirect to page you want to
https://www.youtube.com/watch?v=gQLQ0t9B5yk
if you want to understand more
Answered By - Sohel Bepari
Answer Checked By - Pedro (JavaFixing Volunteer)