title: What is the Life Cycle of an Object created inside / outside a Servlet? Will that object die when the session expire?
body: <p>Ok, let say in my <code>LoginServlet.java</code></p>
  
  <pre><code>User user1=new User();
  session.setMaxInactiveInterval(5*60); //each session last 5 min;
  session.setAttribute("user", user1);
  
  currentOnlineUsersList.add(user1); //this is public static List
  </code></pre>
  
  <p>Now 5 mins later, the <code>session</code> of <code>user1</code> expire, at this point of time, we print out all users</p>
  
  <pre><code>for (User u : currentOnlineUsersList){
    System.out.println(u);
  }
  </code></pre>
  
  <p>Will <code>user1</code> in the printout list?</p>
  
  <p>The question is that:</p>
  
  <p>Will <code>user1</code> die when the session expire?</p>
  
  <p>What is the Life Cycle of an Object created inside / outside a Servlet?</p>