Java Servlet Programing Laungage

Java Servlet Projects

Servlet Project 3

Java Servlet :Cookies
Previous Home Next

Cookies:A cookie represents textual information in the form of key value pair that is sent by the server as part of the response to the client machine and is sent by the clien to the server with substituent requests.Cookies provide a simple mechanism for maintaining information between requests.

Cookies can be of two types:

  1. Persistent cookies remain valid for multiple session.They are stored by the browser in a text file on the client machine.
  2. Non-persistent cookies remain valid only for a single session.They are stored by the browser in its cache and are discarded when communication with the server is terminated.


javax.servlet.http.Cookie Class provides object representation of cookies.

A cookie object can be created using following constructor:

public Cookie(String key,String value);
Previous Home Next