Methods in the Cookie API
getDomain/setDomain
Lets you specify domain to which cookie applies. Current
host must be part of domain specified
getMaxAge/setMaxAge
Gets/sets the cookie expiration time (in seconds). If you
fail to set this, cookie applies to current browsing session
only. See LongLivedCookie helper class given earlier
getName/setName
Gets/sets the cookie name. For new cookies, you supply
name to constructor, not to setName. For incoming
cookie array, you use getName to find the cookie of
interest
83
Servlets
www.corewebprogramming.com
Methods in the Cookie API
(Continued)
getPath/setPath
Gets/sets the path to which cookie applies. If unspecified,
cookie applies to URLs that are within or below directory
containing current page
getSecure/setSecure
Gets/sets flag indicating whether cookie should apply
only to SSL connections or to all connections
getValue/setValue
Gets/sets value associated with cookie. For new cookies,
you supply value to constructor, not to setValue. For
incoming cookie array, you use getName to find the
cookie of interest, then call getValue on the result
84
Servlets
www.corewebprogramming.com
42