title: Testing if a User is Logged in Via JSP/Spring-MVC
body: <p>Using Spring 3 MVC and JSP, I simply want to test if a user is logged in, I'm not interested in using Spring Security currently</p>
  
  <pre><code>&lt;jsp:useBean id="myAppUser" type="com.xxx.MyUser" beanName="myUser" scope="session" /&gt;
  &lt;c:choose&gt;
      &lt;c:when test="myUser.loggedIn"&gt;
          //dostuff
      &lt;/c:when&gt;
      &lt;c:otherwise&gt;
          //dootherstuff
      &lt;/c:otherwise&gt;
  &lt;/c:choose&gt;
  </code></pre>
  
  <p>But the problem is that when there isn't yet a myAppUser in the session, jsp:useBean throws an exception.  Now I realize that I can have the JSP:useBean actually instantiate the object by giving it a class, but I don't like knowing that somewhere in some JSP fragment I have objects being instantiated and added to my session, so I either want to always set an initial value for that user, and have control over it programatically, or I'd like a way to get that bean that allows it to be null or not exist, if it doesn't exist just return null</p>
  
  <p>either way would be fine</p>
  
  <p>if my question points to a fundamental misunderstanding in what I should be doing please provide a link to documentation that will thoroughly explain this use case</p>