Which code snippet on line 14 (//your code here), will determine the age of the session?

As a convenience feature, your web pages include an Ajax request every five minutes to a special servlet that monitors the age of the user’s session. The client-side JavaScript that handles the Ajax callback displays a message in the screen as the session ages. The Ajax call does NOT pass any cookies, but it passes the session ID in a request parameter called session ID. In addition, assume that your web app keeps a hash map of session objects by the ID. Here is a partial implementation of this servlet:
public class SessionAgeServlet extends HttpServlet {
public void service(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
String sessionID = request.getParameter("sessionID");
HttpSession session = getSession(sessionID);
long age = //your code here
response.getWriter().print(age);
} …//more code here
}
Which code snippet on line 14 (//your code here), will determine the age of the session?
A. session.getMaxInactiveInterval();
B. session.getLastAccessed().getTime() – session.getCreationTime().getTime();
C. session.getLastAccessedTime().getTime() – session.getCreationTime().getTime();
D. session.getLastAccessed() – session.getCreationTime();
E. session.getMaxInactiveInterval() – session.getCreationTime();
F. session.getLastAccessedTime() – session.getCreationTime();

Download Printable PDF. VALID exam to help you PASS.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.