public abstract class CookieBuilder extends Object
Cookies
service.Modifier and Type | Field and Description |
---|---|
protected String |
comment |
protected String |
domain |
protected Boolean |
httpOnly |
protected Integer |
maxAge |
protected String |
name |
protected String |
path |
protected Boolean |
secure |
protected String |
value |
protected int |
version |
Modifier | Constructor and Description |
---|---|
protected |
CookieBuilder(String name,
String value)
Initialize a new CookieBuilder
|
Modifier and Type | Method and Description |
---|---|
abstract void |
delete()
Deletes the cookie.
|
CookieBuilder |
setComment(String comment)
Comments are not supported by version 0 (the default) cookies
|
CookieBuilder |
setDomain(String domain)
Set the domain for the cookie to be created.
|
CookieBuilder |
setHttpOnly(boolean httpOnly)
Set the cookie's httpOnly mode.
|
CookieBuilder |
setMaxAge(int maxAge)
Set how long the cookie should live.
|
CookieBuilder |
setPath(String path)
Set the path for the cookie to be created.
|
CookieBuilder |
setSecure(boolean secure)
Set the cookie's secure mode.
|
CookieBuilder |
setVersion(int version)
Version 0 complies with the original Netscape cookie specification.
|
abstract void |
write()
Sets defaults and writes the cookie to the client.
|
protected int version
protected CookieBuilder(String name, String value)
name
- the name of the resulting cookievalue
- the value of the resulting cookiepublic CookieBuilder setPath(String path)
Request.getContextPath()
.path
- the path for the cookieCookieBuilder
public CookieBuilder setDomain(String domain)
domain
- the domain for the cookieCookieBuilder
public CookieBuilder setMaxAge(int maxAge)
0
deletes a cookie, a value of
-1
deletes a cookie upon closing the browser. The default is defined by
the symbol org.apache.tapestry5.default-cookie-max-age
. The factory default for
this value is the equivalent of one week.maxAge
- the cookie's maximum age in secondsCookieBuilder
public CookieBuilder setSecure(boolean secure)
Request.isSecure()
.secure
- whether to send the cookie over a secure channel onlyCookieBuilder
public CookieBuilder setHttpOnly(boolean httpOnly)
httpOnly
- prevents javascript access to this cookieCookieBuilder
public CookieBuilder setVersion(int version)
version
- numberCookieBuilder
public CookieBuilder setComment(String comment)
comment
- for cookieCookieBuilder
public abstract void write()
public abstract void delete()
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.