title: How to check if User Logged in or Not using Session Struts 2
body: <p>I am working on struts2. I use below code to check if the User have logged in or not </p>
  
  <pre><code>public String execute()
  {
     HttpServletRequest request = ServletActionContext.getRequest();
     HttpSession        session = request.getSession(false);
  
     System.out.println(session);
  
     if(session == null)
     {
        return "UserLoggedIn";    
     }
  
     return "success";
  }
  </code></pre>
  
  <p>When I access print the session value in console first time it print null. But when I do the same thing by refreshing the page it prints some thing like below and its ends up letting the user to access the page with out logging in.</p>
  
  <pre><code>org.apache.catalina.session.StandardSessionFacade@16f21478
  </code></pre>
  
  <p>How to carry out session checking to see whether user logged in or not.</p>
  
  <p>Thank you very much.</p>