Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

session.invalidate() is sometimes not working and not destroying the session object. What should I do?

$
0
0
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 ;)


Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>