Forums Register Login

A mock question about session

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
It says very clearly :You want to let the user to be logged in only for 20 minutes.
getMaxAge() is the answer. My last word
+Pie Number of slices to send: Send
 

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???
+Pie Number of slices to send: Send
getCreationTime() is the correct answer. Return time in milliseconds.

1 second = 1000 milliseconds.

Refer page 242 of HFSJ Book. The Question says only HttpSession Method and not Cookie class methods. As getMaxAge() is a cookie class method.
Don't MAKE me come back there with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 643 times.
Similar Threads
Increasing the session time out
session timeout
About the Session
Session Timeout Timer Reset
How to prompt user that session is going to time out ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:38:41.