Your web application logs a user in when she supplies username/password. At that time a session is created for the user. Your want to let the user to be logged in only for 20 minutes. The application should redirect the user to the login page upon any request after 20 minutes of activity. Which of the following HttpSession methods would be helpful to you for implementing this functionality?
Select 1 correct option. a getMaxInactiveInterval()
b getMaxActiveInterval()
c getLastAccessTime()
d getLastAccessedTime()
e getCreationTime()
answer:e But I think d is more eligible for this scenario.Correct me if I was wrong.
getCreationTime() returns the time the session was first created. You subtract from the current time the time returned by getCreationTime() and you see if the session has expired. So the correct answer is E.
getLastAccessedTime() returns the last time the Container got a request from that user, which is of no use to you to find out the total time he has been in a session.
All these assume login/logout=session creation/destroy....but, I just cannot find anything in the spec dictating the container to create a session when a user login (assuming he is using declarative security mechanism).
I heard in the forum that session can be created destroyed and replaced with another session while the user is still login.
Appreciate if anyone can give more info on this area.
But question says that the application should redirect the user to the login page upon any request after 20 minutes of activity. So I think it means if user don't send any request exceed 20 minutes. So I think getLastAccessedTime is the best method. Correct me if I was wrong.
Originally posted by Catalin Morosan: getCreationTime() returns the time the session was first created. You subtract from the current time the time returned by getCreationTime() and you see if the session has expired. So the correct answer is E.
getLastAccessedTime() returns the last time the Container got a request from that user, which is of no use to you to find out the total time he has been in a session.
hope I was clear
you given 2 answer, which is "getCreationTime()" and "getMaxAge()"..so which is the correct one???