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 are the kinds of http requests?
What’s the difference between forward() and sendredirect() methods?
Is it possible to have a constructor inside the servlet?
What are the different methods involved in the process of session management in servlets?
Which protocol will be used by browser and servlet to communicate
What is lazy loading and what is Generic Servlet Class?
What exactly are the functions of servlet?
What is servlet attributes and their scope?
What is SingleThreadModel interface?
Why the container loads server at the application startup and how?
What is the effective way to make sure all the servlets are accessible only when user has a valid session?
Define servlet mapping?
How will two or three servlets interact or communicate with each other?
What are different ways for authentication of servlet?
What is servlet and its life cycle?