nerdexam
GIAC

GSNA · Question #58

GSNA Question #58: Real Exam Question with Answer & Explanation

The correct answer is A. Cookie [] cookies = request.getCookies();. The getCookies() method of the HttpServletRequest interface is used to get the cookies from a client. This method returns an array of cookies. Answer: B, C are incorrect. The getCookie(String str) method does not exist. Answer: D is incorrect. The getCookies() method is present i

Question

Which of the following methods is used to get a cookie from a client? Note: Here, request is a reference of type HttpServletRequest, and response is a reference of type HttpServletResponse.

Options

  • ACookie [] cookies = request.getCookies();
  • BCookie [] cookies = request.getCookie(String str)
  • CCookie [] cookies = response.getCookie(String str)
  • DCookie [] cookies = response.getCookies()

Explanation

The getCookies() method of the HttpServletRequest interface is used to get the cookies from a client. This method returns an array of cookies. Answer: B, C are incorrect. The getCookie(String str) method does not exist. Answer: D is incorrect. The getCookies() method is present in the HttpServletRequest interface and not in the HttpServletResponse interface.

Community Discussion

No community discussion yet for this question.

Full GSNA Practice