title: Declaring HttpSession Object in Controller
body: <p>We have defined a controller and need to declare the HttpSession object. I can autowire it or pass as an object to the method.  What is the difference between  the two options and which is preferable?</p>
  
  <p>Option 1</p>
  
  <pre><code>@Controller
  public class UserController {
  
      @Autowired
      HttpSession session;
      ..
      ..
  }
  </code></pre>
  
  <p>Option 2</p>
  
  <pre><code>@Controller
  public class UserController {
  
      @RequestMapping(value="/user", method=RequestMethod.GET)
      public @ResponseBody User getUser(HttpSession session) {
      ..
      ..
      }
  }
  </code></pre>