Let's say I have a LoginServlet. Java
Now, 5 minutes later, user1's session expires; at this point, we print out all users.
Will user1 be included in the printable list?
The query is as follows:
Will user1 perish after the session ends?
What is the Life Cycle of an Object Created Within/Outside of a Servlet?
Source: Scalers
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
Now, 5 minutes later, user1's session expires; at this point, we print out all users.
Code:
for (User u : currentOnlineUsersList){
System.out.println(u);
}
Will user1 be included in the printable list?
The query is as follows:
Will user1 perish after the session ends?
What is the Life Cycle of an Object Created Within/Outside of a Servlet?
Source: Scalers