title: HttpSessionEvent getSession().getId() returning same Id even after session is invalidated on Websphere not on Tomcat
body: <p>I have a sample Spring MVC application with SessionListener as:</p>
  
  <pre><code>public class SessionListener implements HttpSessionListener {
      public void sessionCreated(HttpSessionEvent e) {
          logger.info("Session created: " + e.getSession().getId());
      }
  
      public void sessionDestroyed(HttpSessionEvent e) {
          logger.info("Session destroyed: " + e.getSession().getId());
      }
  }
  </code></pre>
  
  <p>and a custom controller as:-</p>
  
  <pre><code>@Controller
  public class SessionInvalidateController {
      @RequestMapping("/invalidateSession")
      void clearSession(HttpSession session) {
          session.invalidate();
      }
  }
  </code></pre>
  
  <p>The Conversion Pattern of Log4j.xml file is as to log the session listener events:-
  </p>
  
  <p>When I hit the /invalidateSession URL from the application. It successfully invalidate the session and I got the logs which got me scratching my head. </p>
  
  <p>The log snippet that I got is:-</p>
  
  <blockquote>
    <p>Session destroyed: 4c3kpUbJt1zvCeOHWJkxpJY<br>
    Session created: <strong>4c3kpUbJt1zvCeOHWJkxpJY</strong></p>
  </blockquote>
  
  <p>I checked the HttpSessionEvent code which is returning the id from the HTTPSession. Link for the code: <a href="http://grepcode.com/file/repo1.maven.org/maven2/javax.servlet/servlet-api/2.4/javax/servlet/http/HttpSession.java#HttpSession.getId%28%29" rel="nofollow">http://grepcode.com/file/repo1.maven.org/maven2/javax.servlet/servlet-api/2.4/javax/servlet/http/HttpSession.java#HttpSession.getId%28%29</a>.</p>
  
  <p>Then I ran the same code on Tomcat 7 and I am getting the changed IDs.</p>
  
  <pre><code>Session destroyed: 4C7B0754969FE4EA98E351522C38E79F
  Session created: 3BBA7D0968A49446D68E5505B9ECF124
  </code></pre>
  
  <p>Though the documentation clearly says that:</p>
  
  <blockquote>
    <p><strong>unique identifier assigned to this session</strong></p>
  </blockquote>
  
  <p>The question arises here is why this ID is not changing? Am I missing something or this is <strong>an expected behavior</strong>?</p>