What are cookies and how will you use them?

Answers were Sorted based on User's Feedback



What are cookies and how will you use them?..

Answer / 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

What are cookies and how will you use them?..

Answer / tulasi vani

Cookies are small bit of textual information that are sent
from the webserver to the browser and sent back from the
browser to the server without changing the data later.

Cookies are helpful during e-commerce sessions when it will
be possible to recoginise a user during a session or it
helps in advertising as we can know the user preferences.

Cookies are created using:

Cookie c=new Cookie("name",value);
response.addCookie(c);

you can retrive the cookie value using:

request.getCookie() which returns a String giving the name
of the cookie and the value associated with the cookie.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Servlets Interview Questions

How we can get ip address of client in servlet?

0 Answers  


Explain Servlet Chaining ?

2 Answers  


What is lazy loading and what is Generic Servlet Class?

0 Answers  


What are different ways for authentication of servlet?

0 Answers  


Why servlet is faster than jsp?

0 Answers  






How can the session in servlet be destroyed?

0 Answers  


What is the difference between an applet and a servlet?

15 Answers   GCEW, Miracle Solutions,


What is servlet and its life cycle?

0 Answers  


How multiple simultaneous requests can be handled by servlets?

2 Answers  


Can you refresh servlet in client and server-side automatically?

0 Answers  


What are the different mode that servlets can be used?

0 Answers  


What is use of parseQueryString?

1 Answers  


Categories