O'Reilly logo

JavaServer Pages, Second Edition by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Cookie

Synopsis

A Cookie object represents an HTTP cookie -- a small amount of information sent by a servlet to a web browser, saved by the browser, and later sent back to the server with new requests. A cookie’s value can uniquely identify a client, so cookies are commonly used for session management. A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number.

This class supports both the Version 0 (the informal specification first introduced by Netscape) and the Version 1 (formally defined by RFC 2109) cookie specifications. By default, cookies are created using Version 0 to ensure the best interoperability.

Synopsis

Class name:

javax.servlet.http.Cookie

Extends:

None

Implements:

Clonable

Implemented by:

Internal container-dependent class. Most containers use the reference implementation of the class (developed in the Apache Jakarta project).

Constructor

public Cookie(String name, String value)

Creates a new instance with the specified name and value. The name must conform to RFC 2109, meaning it can’t contain commas, semicolon, whitespace, or start with a dollar sign.

Methods

public Object clone( )

Overrides the standard Object.clone( ) method to return a copy of this cookie.

public String getComment( )

Returns the comment describing the purpose of this cookie or null if the cookie has no comment. For a cookie received from the browser, this method always returns null.

public ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required