title: How to close a specific session in Java EE
body: <p>How can I close a specific session if i have several session open as follows:</p>
  
  <pre><code>String userName = (String) session.getAttribute("userName");
  HashMap cartList = (HashMap) session.getAttribute("cartList");
  </code></pre>
  
  <p>If i want to close the session of cartList, what code should i use?</p>
  
  <p>I tried using the following: </p>
  
  <ol>
  <li><code>session.invalidate()</code>   but it closes everything. </li>
  <li><code>session.removeAttribute("cartList");</code>  it didn't close my session.</li>
  </ol>