nerdexam
GIAC

GSNA · Question #58

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.

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…

Database & Application Auditing

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()

How the community answered

(33 responses)
  • A
    70% (23)
  • B
    3% (1)
  • C
    9% (3)
  • D
    18% (6)

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.

Topics

#HTTP cookies#HttpServletRequest#Java servlet#web application

Community Discussion

No community discussion yet for this question.

Full GSNA Practice