Oracle
1Z0-899 · Question #179
1Z0-899 Question #179: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-899 to reveal the answer and full explanation for question #179. The question stem and answer options stay visible for context.
Question
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 on 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 sessionID. In addition, assume that your webapp keeps a hasmap of session objects by the ID. Here is a partial implementation of this servlet: 10. public class SessionAgeServlet extends HttpServlet { 11. public void service(HttpServletRequest request, HttpServletResponse) throws IOException { 12. String sessionID = request.getParameter("sessionID"); 13. HttpSession session = getSession(sessionID); 14. long age = // your code here 15. response.getWriter().print(age); 16. } ... // more code here 47. } Which code snippet on line 14, will determine the age of the session?
Options
- Asession.getMaxInactiveInterval();
- Bsession.getLastAccessed().getTime() ?session.getCreationTime().getTime();
- Csession.getLastAccessedTime().getTime() ?session.getCreationTime().getTime();
- Dsession.getLastAccessed() - session.getCreationTime();
- Esession.getMaxInactiveInterval() ?session.getCreationTime();
- Fsession.getLastAccessedTime() ?session.getCreationTime();
Unlock 1Z0-899 to see the answer
You've previewed enough free 1Z0-899 questions. Unlock 1Z0-899 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.