Public class Logout extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session = req.getSession();
session.invalidate();
RequestDispatcher rd = req.getRequestDispatcher("/index.html");
rd.forward(req, resp);
}
}
I am doing this in eclipse on Apache Tomcat server. When I restart the server sometimes the session object deletes but majority times it does not. In new browser I can still fetch the details after session.invalidate() is called.
I tried many other things like -
- a return statement after RequestDispatcher.
- and i even tried the below code as well -
HttpSession session = request.getSession(false);
if (session != null)
session.setMaxInactiveInterval(1);
Nothing worked for me ;)