|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.velocity.tools.view.tools.CookieTool
View tool for convenient cookie access and creation.
Template example(s):
$cookie.foo.value
$cookie.add("bar",'woogie')
Toolbox configuration:
<tool>
<key>cookie</key>
<scope>request</scope>
<class>org.apache.velocity.tools.view.tools.CookieTool</class>
</tool>
This class is only designed for use as a request-scope tool.
| Field Summary | |
protected javax.servlet.http.HttpServletRequest |
request
|
protected javax.servlet.http.HttpServletResponse |
response
|
| Constructor Summary | |
CookieTool()
|
|
| Method Summary | |
void |
add(java.lang.String name,
java.lang.String value)
Adds a new Cookie with the specified name and value to the HttpServletResponse. |
void |
add(java.lang.String name,
java.lang.String value,
int maxAge)
Convenience method to add a new Cookie to the response and set an expiry time for it. |
javax.servlet.http.Cookie |
get(java.lang.String name)
Returns the Cookie with the specified name, if it exists. |
javax.servlet.http.Cookie[] |
getAll()
Expose array of Cookies for this request to the template. |
void |
init(java.lang.Object obj)
Initializes this instance for the current request. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpServletResponse response
| Constructor Detail |
public CookieTool()
| Method Detail |
public void init(java.lang.Object obj)
init in interface ViewToolobj - the ViewContext of the current requestpublic javax.servlet.http.Cookie[] getAll()
This is equivalent to $request.cookies.
public javax.servlet.http.Cookie get(java.lang.String name)
So, if you had a cookie named 'foo', you'd get it's value
by $cookies.foo.value or it's max age
by $cookies.foo.maxAge
public void add(java.lang.String name,
java.lang.String value)
name - the name to give this cookievalue - the value to be set for this cookie
public void add(java.lang.String name,
java.lang.String value,
int maxAge)
name - the name to give this cookievalue - the value to be set for this cookiemaxAge - the expiry to be set for this cookie
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||