nerdexam
Oracle

1Z0-899 · Question #10

Given an HttpServletRequest request and an httpServletResponse response: 41. HttpSession session = null; 42. / / insert code here 43. if (session = = null) { 44. / / do something if session does not…

The correct answer is D. session = request.getSession (false). See the full explanation below for the reasoning.

Question

Given an HttpServletRequest request and an httpServletResponse response: 41. HttpSession session = null; 42. / / insert code here 43. if (session = = null) { 44. / / do something if session does not exist 45. } else { 46. / / do something if session exists 47. } To implement the design intent, which statement must be inserted at line 42?

Options

  • Asession = response.getSession ();
  • Bsession = request.getSession ();
  • Csession = request.getSession (true);
  • Dsession = request.getSession (false);
  • Esession = request.getSession ("jsessionid");

How the community answered

(28 responses)
  • A
    7% (2)
  • B
    4% (1)
  • C
    7% (2)
  • D
    82% (23)

Community Discussion

No community discussion yet for this question.

Full 1Z0-899 Practice