Sr.Java Web Developer Question:

Tell me how does cookies work in Servlets?

Tweet Share WhatsApp

Answer:

☛ Cookies are text data sent by server to the client and it gets saved at the client local machine.
☛ Servlet API provides cookies support through javax.servlet.http.Cookie class that implements Serializable and Cloneable interfaces.
☛ HttpServletRequest getCookies() method is provided to get the array of Cookies from request, since there is no point of adding Cookie to request, there are no methods to set or add cookie to request.
☛ Similarly HttpServletResponse addCookie(Cookie c) method is provided to attach cookie in response header, there are no getter methods for cookie.

Download Sr.Java Web Developer PDF Read All 64 Sr.Java Web Developer Questions
Previous QuestionNext Question
Tell us what kind of HTTP request does the <a href="url">text</a> generate?Tell me what are the reasons for a page not found error and how will you sort it out?