title: Spring MVC 3.0 accessing Session Variable
body: <p>I have the following problem, I have configured the following class which should be stored in session.</p>
  
  <pre><code>&lt;bean id="Users" class="com.doolloop.DlUser" scope="session"&gt;
  &lt;aop:scoped-proxy/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Then I in my Dispatcher servlet I would like to access this class user and set </p>
  
  <pre><code>@RequestMapping(value="/authenticate.do",method = RequestMethod.POST)
            public String sampleAuthentication(@Valid Person person, BindingResult result,
                    Map model,HttpServletRequest request){
                      ...... /some code
    HttpSession session = request.getSession();
            DlUser user = (DlUser) session.getAttribute("Users");
                    /// some uses for user object
  
  }
  </code></pre>
  
  <p>The problem is that I'm always getting null Value of user object.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Second problem, I read in articles that accessing <code>HttpSession</code> is not thread-safe, how can it be done safe way? Should be kind of Singleton? Why this is not Thread Safe operation?</p>
  
  <p>Thank you in advance.</p>
  
  <p>Danny.    </p>