Answer Posted / janet
Cookies are a mechanism that a servlet uses to have a
client hold a small amount of state-information associated
with the user.
a) create a cookie with the cookie constructor:
public Cookie(String name,String value)
b) A Servlet can send a cookie to the client by passing a
Cookie object to the addCookie() method of
HttpServletResponse:
public void HttpServletResponse.addCookie(Cookie
cookie)
c) A servlet retrieves cookie by calling the getCookies()
method of HttpServletRequest:
public Cookie[]HttpServletRequest.getCookie().
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Which interface must be implemented by all servlets?
What is the difference between servlet and filter?
Is servlet synchronized?
What do you mean by request dispatcher in servlet? Also explain its methods.
Can you create a deadlock condition on a servlet?
How is the get () method different from the post() method?
Which event is fired at the time of project deployment and undeployment?
Can you call a jsp from the servlet?
Define the lifecycle for executing a jsp page.
What is the GenericServlet class?
What is servlet container. how it works?
Difference between forward() method and sendredirect() method ?
What are the different methods of session management in servlets?
What is ServletConfig object?
What is string tokenizer?