title: Problem with request.getSession
body: <p>I have a servlet LogMeOut.java where I am writing the following code:</p>
  
  <pre><code>HttpSession session = request.getSession(false);
  if (session != null){
     //statements to delete my cookies //
     session.invalidate();
  }
  </code></pre>
  
  <p>My problem is when I am calling the LogMeOut for the first time from a jsp, it gives a request object with no session. So my <code>session.invalidate</code> is not working.
  But if I go back to my jsp and then call the same LogMeOut, this time the request object contains the correct session and it works.
  Any idea why? Or where should I start looking?</p>