Oracle
1Z0-899 · Question #65
Given an HttpServletRequest request and HttpServletResponse response, which sets a cookie "username" with the value "joe" in a servlet?
The correct answer is F. response.addCookie(new Cookie("username", "joe")). See the full explanation below for the reasoning.
Question
Given an HttpServletRequest request and HttpServletResponse response, which sets a cookie "username" with the value "joe" in a servlet?
Options
- Arequest.addCookie("username", "joe")
- Brequest.setCookie("username", "joe")
- Cresponse.addCookie("username", "joe")
- Drequest.addHeader(new Cookie("username", "joe"))
- Erequest.addCookie(new Cookie("username", "joe"))
- Fresponse.addCookie(new Cookie("username", "joe"))
- Gresponse.addHeader(new Cookie("username", "joe"))
How the community answered
(28 responses)- A4% (1)
- C14% (4)
- F75% (21)
- G7% (2)
Community Discussion
No community discussion yet for this question.