title: Java HttpSession .getAttribute(String name)
body: <p>I have a simple, short question but not found the answer anywhere. I created an HttpSession and want to get an attribute from it, for example a User object.</p>
  
  <pre><code>HttpSession session = request.getSession(true);
  Object userObject = session.getAttribute("name");
  if ((userObject != null) &amp;&amp; (userObject instanceof User)) {
      User currentUser = (User) userObject;
      ...
  }
  </code></pre>
  
  <p>The question is the following: .getAttribute function gets a String name as parameter - what is the name? From where do I know the name? Is it predefined somewhere? - then where to define another one?</p>
  
  <p>Thank you!</p>