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
How to create war file?
What are the different ways we can maintain state between requests?
Explain the role of dispatcherservlet and contextloaderlistener.
Is servlet thread safe?
How native code can be used in a servlet?
Explain the steps involved in placing a servlet within a package?
What are all the advantages of servlet over cgi?
What is the major difference between context parameter and context attribute?
What is servlet and its life cycle?
Does servlet have main method?
How to find whether a parameter exists in the request object?
what is multiple server?
What's the architecture of a servlet package?
Is that servlet is pure java object or not?
Which application server is best for java?