title: Session attribute access and converting to int?
body: <p>I have stored user id in Session using following command in Servlet:</p>
  
  <pre><code>HttpSession session = request.getSession();
  session.setAttribute("user", user.getId());
  </code></pre>
  
  <p>Now, I want to access that user id from another Servlet:</p>
  
  <pre><code>HttpSession session = request.getSession(false);
  int userid = (int) session.getAttribute("user"); // This is not working
  
  OR
  
  User user = new User();
  user.setId(session.getAttribute("user")); This ain't possible (Object != int)
  </code></pre>
  
  <p>Question: </p>
  
  <ol>
  <li>How can I cast to int and send the id to DAO for SELECT statement</li>
  </ol>