<html> | |
<head> | |
<title>Velocity - CookieTool</title> | |
<meta name="author" value="Gabriel Sidler"/> | |
<meta name="email" value="sidler@apache.org" /> | |
</head> | |
<body bgcolor="#ffffff" text="#000000" link="#525D76" | |
alink="#525D76" vlink="#525D76"> | |
<table border="0" width="100%" cellspacing="4"> | |
<tr><td colspan="2"> | |
<a href="http://jakarta.apache.org/"> | |
<img src="http://jakarta.apache.org/images/jakarta-logo.gif" | |
align="left" alt="The Jakarta Project" border="0"/> | |
</a> | |
<a href="index.html"> | |
<img src="../images/velocityview.png" align="right" alt="< Tools - View >" border="0"/> | |
</a> | |
</td></tr> | |
<tr> | |
<td colspan="2"> | |
<hr noshade="" size="1"/> | |
</td> | |
</tr> | |
<tr> | |
<td width="20%" valign="top" nowrap="true"> | |
<p><strong><a href="../index.html">Velocity Tools</a></strong></p> | |
<p> | |
<strong>VelocityView</strong> | |
</p> | |
<ul> | |
<li><a href="index.html">Overview</a></li> | |
<li><a href="../index.html#Download">Download</a></li> | |
<li><a href="index.html#Installation">Installation</a></li> | |
<li><a href="index.html#VelocityLayoutServlet">LayoutServlet</a></li> | |
<li><a href="index.html#Examples">Examples</a></li> | |
<li><a href="../javadoc/index.html">Javadoc</a></li> | |
</ul> | |
<p> | |
<strong>VelocityView Tools</strong> | |
</p> | |
<ul> | |
<li><a href="../javadoc/org/apache/velocity/tools/view/tools/AbstractPagerTool.html">AbstractPagerTool</a></li> | |
<li><a href="../javadoc/org/apache/velocity/tools/view/tools/AbstractSearchTool.html">AbstractSearchTool</a></li> | |
<li><a href="../javadoc/org/apache/velocity/tools/view/tools/BrowserSnifferTool.html">BrowserSnifferTool</a></li> | |
<li><a href="CookieTool.html">CookieTool</a></li> | |
<li><a href="ImportTool.html">ImportTool</a></li> | |
<li><a href="LinkTool.html">LinkTool</a></li> | |
<li><a href="ParameterParser.html">ParameterParser</a></li> | |
<li><a href="ViewRenderTool.html">ViewRenderTool</a></li> | |
</ul> | |
<p> | |
<strong>Other Subprojects</strong> | |
</p> | |
<ul> | |
<li><a href="../generic/">GenericTools</a></li> | |
<li><a href="../struts/">VelocityStruts</a></li> | |
</ul> | |
<p> | |
</p> | |
</td> | |
<!-- RIGHT SIDE MAIN BODY --> | |
<td colspan="1" valign="top" align="left"> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="CookieTool Reference Documentation"> | |
<strong>CookieTool Reference Documentation</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p>View tool for convenient cookie access and creation.</p> | |
<table cellpadding="0" cellspacing="0"> | |
<tr><td colspan="2"><strong>Class</strong></td></tr> | |
<tr><td> </td><td>org.apache.velocity.tools.view.tools.CookieTool</td></tr> | |
<tr><td colspan="2"><strong>Name</strong></td></tr> | |
<tr><td> </td><td>$cookie (this is the recommended name of the tool in | |
the Velocity context)</td></tr> | |
<tr><td colspan="2"><strong>Toolbox Configuration Example</strong></td></tr> | |
<tr><td> </td><td><pre><tool> | |
<key>cookie</key> | |
<scope>request</scope> | |
<class>org.apache.velocity.tools.view.tools.CookieTool</class> | |
</tool></pre></td></tr> | |
<tr><td colspan="2"><strong>Author(s)</strong></td></tr> | |
<tr><td> </td><td><a href="mailto:mailto:dim@colebatch.com">Dmitri Colebatch</a><br><a href="mailto:nathan@esha.com">Nathan Bubna</a><br></td></tr> | |
</table> | |
<dl> | |
<dt><strong>Method Overview</strong></dt> | |
<dd> | |
<table cellpadding="2" cellspacing="2" border="0"> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getAll()">getAll()</a></td> | |
<td bgcolor="EEEEEE"> | |
Expose array of <code>Cookie</code> objects for this request to the | |
template. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#get()">get()</a></td> | |
<td bgcolor="EEEEEE"> | |
Returns the <code>Cookie</code> with the specified name, if it exists. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#add()">add()</a></td> | |
<td bgcolor="EEEEEE"> | |
Adds a new <code>Cookie</code> with the specified name and value to the | |
<code>HttpServletResponse</code>. | |
</td> | |
</tr> | |
</table> | |
</dd> | |
</dl> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getAll()"> | |
<strong>getAll()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Expose array of <code>Cookie</code> objects for this request to the | |
template. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
Cookie[] getAll() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Returns</strong></dt> | |
<dd> | |
<returns> | |
array of <code>Cookie</code> objects for this request. | |
</returns> | |
</dd> | |
</dl> | |
<p>This method exposes the array of <code>Cookie</code> objects for | |
this request. It is equivalent to <code>$request.cookies</code>.</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>#set($cookies = $cookie.getAll()) | |
#foreach($c in $cookies) | |
$c.getName() | |
#end</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<p>Given that there are two cookies with the names 'foo' and 'bar' in the array | |
this would produce:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>foo | |
bar</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="get()"> | |
<strong>get()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Returns the <code>Cookie</code> with the specified name, if it exists. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
Cookie get(String name) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>name</dt> | |
<dd> | |
<parameter name="name"> | |
The name of the cookie to fetch. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<dl> | |
<dt><strong>Returns</strong></dt> | |
<dd> | |
<returns> | |
A <code>Cookie</code> with the specified name or null if none exists. | |
</returns> | |
</dd> | |
</dl> | |
<p>Returns the <code>Cookie</code> with the specified name, if it exists.</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>$cookie.foo.value</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<p>Given that the cookie 'foo' contains the value 'bar' this would produce:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>bar</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="add()"> | |
<strong>add()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Adds a new <code>Cookie</code> with the specified name and value to the | |
<code>HttpServletResponse</code>. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
void add(String name, String value) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
void add(String name, String value, int maxAge) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>name</dt> | |
<dd> | |
<parameter name="name"> | |
The name to give this cookie. | |
</parameter> | |
</dd> | |
<dt>value</dt> | |
<dd> | |
<parameter name="value"> | |
The value to be set for this cookie. | |
</parameter> | |
</dd> | |
<dt>maxAge</dt> | |
<dd> | |
<parameter name="maxAge"> | |
The expiry to be set for this cookie. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<p>Adds a new Cookie with the specified name and value to the HttpServletResponse. | |
This does *not* add a Cookie to the current request.</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>$cookie.add("bar","woogie")</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
<!-- FOOTER SEPARATOR --> | |
<tr> | |
<td colspan="2"> | |
<hr noshade="" size="1"/> | |
</td> | |
</tr> | |
<!-- PAGE FOOTER --> | |
<tr><td colspan="2"> | |
<div align="center"><font color="#525D76" size="-1"><em> | |
Copyright © 1999-2003, Apache Software Foundation | |
</em></font></div> | |
</td></tr> | |
</table> | |
</body> | |
</html> |