title: Spring 4 HttpSession different for each controller method
body: <p>Say I have two controllers:</p>
  
  <pre><code>@Controller
  public class SetUserController
  {
  
    @PostMapping("/setUser")
    public setUser( @RequestBody User user, HttpSession session)
    {
      session.setAttribute("user", user);
      return "index";
    }
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>@Controller
  public class GetUserController
  {
  
    @GetMapping("/getUser")
    public getUser( HttpSession session)
    {
      User user = (User)session.getAttribute("user");
      return "index";
  
     }
  }
  </code></pre>
  
  <p>In the GetUserController#getUser method the session is a completely new session (isNew=true and it has a different ID), so obviously the session.getAttribute() will always return null. Does the dispatcher servlet create a new HttpSession object for each request? If so... WHY?!</p>
  
  <p>I'm running this on Tomcat 8. </p>