title: Java servlet - Session cleanup (HttpServletRequest)
body: <p>General question about java servlets and the best way to handle requests. If I hit my doGet method from a remote server request:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
    ....
    &lt;do work here&gt;
    ....
    kill(request);
  }
  
  private void kill(HttpServletRequest request) {
  //How do I kill the user session here?
  }
  </code></pre>
  
  <p>After I process the request at my end and generate my output to the requester, I want to basically "kill" their session. Currently, that session lingers and thus eats up memory. Then once the max is reached, all other calls are timed out.</p>
  
  <p>I tried creating a HttpSession object using the request object, but got the same results:</p>
  
  <pre><code>HttpSession session = request.getSession();
  session.invalidate();
  </code></pre>