Name
Cookie
Synopsis
A Cookie
object represents an HTTP cookie—a
small amount of information sent by a server 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, semicolons, 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 returnsnull
.-
public String getDomain( ...
Get JavaServer Pages, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.