Package org.apache.tapestry5.services
Interface Cookies
-
- All Known Implementing Classes:
CookiesImpl
public interface Cookies
Used by other services to obtain cookie values for the current request, or to write cookie values as part of the request. Note that when writing cookies, the cookie's secure flag will matchRequest.isSecure()
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description CookieBuilder
getBuilder(java.lang.String name, java.lang.String value)
Returns aCookieBuilder
to build and write aCookie
.java.lang.String
readCookieValue(java.lang.String name)
Returns the value of the first cookie whose name matches.void
removeCookieValue(java.lang.String name)
Removes a previously written cookie, by writing a new cookie with a maxAge of 0.void
writeCookieValue(java.lang.String name, java.lang.String value)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.void
writeCookieValue(java.lang.String name, java.lang.String value, int maxAge)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.void
writeCookieValue(java.lang.String name, java.lang.String value, java.lang.String path)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.void
writeCookieValue(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.void
writeDomainCookieValue(java.lang.String name, java.lang.String value, java.lang.String domain)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.void
writeDomainCookieValue(java.lang.String name, java.lang.String value, java.lang.String domain, int maxAge)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.
-
-
-
Method Detail
-
readCookieValue
java.lang.String readCookieValue(java.lang.String name)
Returns the value of the first cookie whose name matches. Returns null if no such cookie exists. This method is only aware of cookies that are part of the incoming request; it does not know about additional cookies added since then (viawriteCookieValue(String, String)
).
-
writeCookieValue
void writeCookieValue(java.lang.String name, java.lang.String value)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.Creates or updates a cookie value. The value is stored using a max age (in seconds) defined by the symbolorg.apache.tapestry5.default-cookie-max-age
. The factory default for this value is the equivalent of one week.
-
writeCookieValue
void writeCookieValue(java.lang.String name, java.lang.String value, int maxAge)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.As withwriteCookieValue(String, String)
but an explicit maximum age may be set.- Parameters:
name
- the name of the cookievalue
- the value to be stored in the cookiemaxAge
- the maximum age, in seconds, to store the cookie
-
writeCookieValue
void writeCookieValue(java.lang.String name, java.lang.String value, java.lang.String path)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.As withwriteCookieValue(String, String)
but an explicit path may be set.
-
writeDomainCookieValue
void writeDomainCookieValue(java.lang.String name, java.lang.String value, java.lang.String domain)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.As withwriteCookieValue(String, String)
but an explicit domain may be set.
-
writeDomainCookieValue
void writeDomainCookieValue(java.lang.String name, java.lang.String value, java.lang.String domain, int maxAge)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.As withwriteCookieValue(String, String)
but an explicit domain and maximum age may be set.
-
writeCookieValue
void writeCookieValue(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain)
Deprecated.Use theCookieBuilder
API, obtained withgetBuilder(String, String)
, instead.As withwriteCookieValue(String, String, String)
but an explicit domain and path may be set.
-
removeCookieValue
void removeCookieValue(java.lang.String name)
Removes a previously written cookie, by writing a new cookie with a maxAge of 0. Only deletes a cookie with the default path and no domain set. For deleting other cookies useCookieBuilder.delete()
. An instance of theCookieBuilder
API can be obtained withgetBuilder(String, String)
.
-
getBuilder
CookieBuilder getBuilder(java.lang.String name, java.lang.String value)
Returns aCookieBuilder
to build and write aCookie
. The default implementation creates a cookie who's value is stored using a max age (in seconds) defined by the symbolorg.apache.tapestry5.default-cookie-max-age
. The factory default for this value is the equivalent of one week. The default path is the context path (seeRequest.getContextPath()
) of the current Request, the default secure setting is to send the cookie over secure channels only, if the original request was secure (seeRequest.isSecure()
- Parameters:
name
- the name of the cookievalue
- the value of the cookie- Returns:
- a
CookieBuilder
for setting additional cookie attributes and writing it out - Since:
- 5.4
-
-