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
Explain the difference between generic servlet and http servlet?
How do you get the ip address of the client in servlet?
How can you start a jta transaction from a servlet deployed on jboss?
What are the two important api's in for servlets?
What is the importance of init() method in Servlet ?
How we can call a jsp from the servlet?
What is difference between cookies and httpsession?
What is servlet and its types?
What is servlet api used for conneting database?
How do we share data using 'getservletcontext ()?
What are some advantages of storing session state in cookies?
How to find whether a parameter exists in the request object?
What if we pass negative value in load-on-startup?
Why are servlets used?
What is SingleThreadModel interface?