title: How to validate/invalidate sessions jsp/servlets?
body: <p>I opened the session in my servlet when the user performed a successful login:</p>
  
  <pre><code>HttpSession session = request.getSession(true);
  session.setAttribute("name", name);
  </code></pre>
  
  <p>then I wrote in the logout.jsp to terminate the session:</p>
  
  <pre><code>&lt;%session.invalidate();%&gt;
  </code></pre>
  
  <p>To check if a session is valid I am doing this:</p>
  
  <pre><code>HttpSession session = request.getSession();
  String name = (String) session.getAttribute("name");
  </code></pre>
  
  <p>But it is not working, I am getting the session valid even after the session.invalidate.
  Does anyone understand where am I doing wrong?</p>