I can not correctly implement the completion of the user session. After clicking the button, the back will return me to the authorized window. How to reset a session? Tried through the filters tode fails. In logout, there is already a bend of everything that is possible.

public class LogoutServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html;charset=UTF-8"); String message = "Вы успешно вышли."; HttpSession session = req.getSession(false); Cookie[] cookies = req.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { Cookie cookie = cookies[i]; cookies[i].setValue(null); cookies[i].setMaxAge(0); resp.addCookie(cookie); } } resp.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server resp.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance resp.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale" resp.setHeader("Pragma","no-cache"); //HTTP 1.0 backward session.removeAttribute("name"); session.invalidate(); req.getSession(true); RequestDispatcher rs = req.getRequestDispatcher("WEB-INF/jsp/index.jsp"); req.setAttribute("message", message); rs.forward(req, resp); } 

}

1 answer 1

After clicking the back button, the browser takes the page from the internal cache. Sometimes it is even a separate special cache exclusively for the Back and Forward buttons.

Try pressing the "Back" button to refresh the page.

  • Then even the session attribute is returned and you can go through different tabs. - Bogdan Shulga