wser, one at a time.
Cookies are small amounts of information, which are sent by the Servlet to the Web Browser, saved by the Browser, and later sent back to the Server. The Servlet sends cookies to the browser by using the HttpServletResponse.addCookie(Cookie) method, which adds fields to HTTP response headers to send cookies to the bro
Based on this I am assuming that they have the same effect. No matter if you send info as cookie or thru response headers, all of it will end up as cookie on the client side. Is my understanding correct here??
Ulf Dittmer wrote:If adding cookies was a simple as adding a header then there would be no need for the Cookie class and all that it does. While it's ultimately correct that cookies are transferred as headers, there's a lot more to it than it may seem at first.
Thanks for this explanation. I was confused mainly because in one of the whizlabs mock test.
Choose at least one answer.
a. HttpServletResponse.setCookie(String name, String value)
b. HttpServletResponse.addCookie(Cookie aCookieObject)
c. HttpServletResponse.setCookie(Cookie aCookieObject)
d. HttpServletResponse.addCookie(setCookie(String name, String value)
e. HttpServletResponse.setHeader(String name, String value)
Choices B and E are the correct answers.
B is obvious but for explanation of E above portion was quoted from the api's. I thought of clarifying the portion itself.