Cookie is a small piece of information sent by server to recognize the user. This information is stored at client side in the textual form.

In JSP, cookie is an object of javax.servlet.http.Cookie class. This object is used widely for session management purposes.

Methods of JSP Cookie

Some of the important method of cookie are as follows: –

  • void setMaxAge(int expiry): – This method is used to set the expiry time of cookie. Here, time is represent in the form of seconds.
  • void getMaxAge(): – This method returns the declared time of cookie after which it will expire.
  • String getName(): – This method returns the name of the cookie.
  • void setValue(String value): – This method is used to set associate the value with cookie.
  • String getValue(): – This method returns the value associated with the cookie.

Example of JSP Cookie assessment





Pin It on Pinterest

Share This