In my project I am using HttpSession for maintaining the user state. when I hit the link to logout servlet and logs out successfully but if I press back button it reloads the profile page again.
LogoutServlet.java
HttpSession session=request.getSession(false);
session.invalidate();
response.sendRedirect("index.html");
LoginServlet.java
HttpSession session=request.getSession();
session.setAttribute("userName",u);