title: How to invalidate the session in jsp
body: <p>I am making a project using MVC framework , where in i have created session on multiple pages and on every page there is an anchor tag displaying (logout) where it redirect user to the 1st page (Login Page). What i am trying to do is when user is redirected to the login page it checks that whether there is already an existing session if yes, then it Invalidate's the session and user has to login again.  But my code doesn't work after invalidating the session when i click on submit without filling username/password it still takes the old value...please tell me where am i going wrong??</p>
  
  <pre><code>         &lt;jsp:useBean id="theBean" class="pack.java.MyModel"/&gt;
          &lt;jsp:setProperty name="theBean" property="name" param="userName"/&gt;
           &lt;jsp:setProperty name="theBean" property="pass" param="userPass"/&gt;
           &lt;%@ taglib uri="/WEB-INF/jsp2/taglib1.tld" prefix="easy" %&gt;
           &lt;html&gt;
          &lt;head&gt;
  
          &lt;/head&gt;
          &lt;body &gt;
          &lt;form  method="post"&gt;
          &lt;h1&gt;Login please&lt;/h1&gt;
          Enter username : &lt;input type = text  name = userName  &gt;
            &lt;/br&gt;
          Enter password : &lt;input type = password  name = userPass  &gt;
         &lt;/br&gt;
          &lt;input type = submit name = submit value = submit&gt;
          &lt;/br&gt;
          &lt;%
  
            HttpSession session=request.getSession(false);
  
          if(session!=null)
           {
            session.invalidate();
           }
            String btn = request.getParameter("submit");
           if(btn!=null)
        {
         %&gt;
  
          &lt;easy:myTag/&gt;
         &lt;% 
  
         }
         %&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>