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
What is the importance of init() method in Servlet ?
Can you explain in detail 'javax.servlet' package?
Explain web application directory arrangement?
What are the objects involved when a servlet receives a call from client?
What is the structure of the http response
What is java servlet?
What is http servlet? Explain with the help of an example.
Can a jsp be called using a servlet?
Explain jsessionid and when is it created?
Why is http protocol called as a stateless protocol?
How the servlet is loaded?
What is the difference between Servlet Request and Servlet Context when calling a Request Dispatcher?
What is a cookie What is the difference between session and cookie
What are the steps involved in placing a servlet within a package?
What is the difference in between the httpservlet and generic servlet?