blob: ab9fd6c08f6f2dbda4f813a529336138666bc917 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>Cookie</title>
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
<link rel="shortcut icon" href="/img/jakarta-favicon.ico">
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Cookie";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":42,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":42,"i12":10,"i13":10,"i14":10,"i15":42,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10,"i22":42,"i23":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"],32:["t6","Deprecated Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev&nbsp;Class</li>
<li><a href="../../../jakarta/servlet/http/HttpFilter.html" title="class in jakarta.servlet.http"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?jakarta/servlet/http/Cookie.html" target="_top">Frames</a></li>
<li><a href="Cookie.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">jakarta.servlet.http</div>
<h2 title="Class Cookie" class="title">Class Cookie</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>jakarta.servlet.http.Cookie</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd>java.io.Serializable, java.lang.Cloneable</dd>
</dl>
<hr>
<br>
<pre>public class <span class="typeNameLabel">Cookie</span>
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable</pre>
<div class="block">Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later
sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session
management.
<p>
A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum
age, and a version number. Some Web browsers have bugs in how they handle the optional attributes, so use them
sparingly to improve the interoperability of your servlets.
<p>
The servlet sends cookies to the browser by using the <a href="../../../jakarta/servlet/http/HttpServletResponse.html#addCookie-jakarta.servlet.http.Cookie-"><code>HttpServletResponse.addCookie(jakarta.servlet.http.Cookie)</code></a> method, which adds fields
to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies
for each Web server, 300 cookies total, and may limit cookie size to 4 KB each.
<p>
The browser returns cookies to the servlet by adding fields to HTTP request headers. Cookies can be retrieved from a
request by using the <a href="../../../jakarta/servlet/http/HttpServletRequest.html#getCookies--"><code>HttpServletRequest.getCookies()</code></a> method. Several cookies might have the same name but
different path attributes.
<p>
Cookies affect the caching of the Web pages that use them. HTTP 1.0 does not cache pages that use cookies created
with this class. This class does not support the cache control defined with HTTP 1.1.
<p>
This class supports cookies as defined by <a href="http://www.ietf.org/rfc/rfc6265.txt">RFC 6265</a>.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../serialized-form.html#jakarta.servlet.http.Cookie">Serialized Form</a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#Cookie-java.lang.String-java.lang.String-">Cookie</a></span>(java.lang.String&nbsp;name,
java.lang.String&nbsp;value)</code>
<div class="block">Constructs a cookie with the specified name and value.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t6" class="tableTab"><span><a href="javascript:show(32);">Deprecated Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>java.lang.Object</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#clone--">clone</a></span>()</code>
<div class="block">Overrides the standard <code>java.lang.Object.clone</code> method to return a copy of this Cookie.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#equals-java.lang.Object-">equals</a></span>(java.lang.Object&nbsp;obj)</code>&nbsp;</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getAttribute-java.lang.String-">getAttribute</a></span>(java.lang.String&nbsp;name)</code>
<div class="block">Gets the value of the cookie attribute associated with the given name.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>java.util.Map&lt;java.lang.String,java.lang.String&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getAttributes--">getAttributes</a></span>()</code>
<div class="block">Returns an unmodifiable mapping of all cookie attributes set via <a href="../../../jakarta/servlet/http/Cookie.html#setAttribute-java.lang.String-java.lang.String-"><code>setAttribute(String, String)</code></a> as well as any
predefined setter method, except for <code>version</code>.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getComment--">getComment</a></span>()</code>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;
<div class="block"><span class="deprecationComment">This is no longer required with RFC 6265</span></div>
</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getDomain--">getDomain</a></span>()</code>
<div class="block">Gets the domain name of this Cookie.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getMaxAge--">getMaxAge</a></span>()</code>
<div class="block">Gets the maximum age in seconds of this Cookie.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getName--">getName</a></span>()</code>
<div class="block">Returns the name of the cookie.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getPath--">getPath</a></span>()</code>
<div class="block">Returns the path on the server to which the browser returns this cookie.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getSecure--">getSecure</a></span>()</code>
<div class="block">Returns <code>true</code> if the browser is sending cookies only over a secure protocol, or <code>false</code> if the
browser can send cookies using any protocol.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getValue--">getValue</a></span>()</code>
<div class="block">Gets the current value of this Cookie.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#getVersion--">getVersion</a></span>()</code>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;
<div class="block"><span class="deprecationComment">This is no longer required with RFC 6265</span></div>
</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#hashCode--">hashCode</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#isHttpOnly--">isHttpOnly</a></span>()</code>
<div class="block">Checks whether this Cookie has been marked as <i>HttpOnly</i>.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setAttribute-java.lang.String-java.lang.String-">setAttribute</a></span>(java.lang.String&nbsp;name,
java.lang.String&nbsp;value)</code>
<div class="block">Sets the value of the cookie attribute associated with the given name.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setComment-java.lang.String-">setComment</a></span>(java.lang.String&nbsp;purpose)</code>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;
<div class="block"><span class="deprecationComment">This is no longer required with RFC 6265</span></div>
</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setDomain-java.lang.String-">setDomain</a></span>(java.lang.String&nbsp;domain)</code>
<div class="block">Specifies the domain within which this cookie should be presented.</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setHttpOnly-boolean-">setHttpOnly</a></span>(boolean&nbsp;httpOnly)</code>
<div class="block">Marks or unmarks this Cookie as <i>HttpOnly</i>.</div>
</td>
</tr>
<tr id="i18" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setMaxAge-int-">setMaxAge</a></span>(int&nbsp;expiry)</code>
<div class="block">Sets the maximum age in seconds for this Cookie.</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setPath-java.lang.String-">setPath</a></span>(java.lang.String&nbsp;uri)</code>
<div class="block">Specifies a path for the cookie to which the client should return the cookie.</div>
</td>
</tr>
<tr id="i20" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setSecure-boolean-">setSecure</a></span>(boolean&nbsp;flag)</code>
<div class="block">Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.</div>
</td>
</tr>
<tr id="i21" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setValue-java.lang.String-">setValue</a></span>(java.lang.String&nbsp;newValue)</code>
<div class="block">Assigns a new value to this Cookie.</div>
</td>
</tr>
<tr id="i22" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#setVersion-int-">setVersion</a></span>(int&nbsp;v)</code>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;
<div class="block"><span class="deprecationComment">This is no longer required with RFC 6265</span></div>
</div>
</td>
</tr>
<tr id="i23" class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/servlet/http/Cookie.html#toString--">toString</a></span>()</code>&nbsp;</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>finalize, getClass, notify, notifyAll, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="Cookie-java.lang.String-java.lang.String-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>Cookie</h4>
<pre>public&nbsp;Cookie(java.lang.String&nbsp;name,
java.lang.String&nbsp;value)</pre>
<div class="block">Constructs a cookie with the specified name and value.
<p>
The name must conform to RFC 6265. However, vendors may provide a configuration option that allows cookie names
conforming to the original Netscape Cookie Specification to be accepted.
<p>
The name of a cookie cannot be changed once the cookie has been created.
<p>
The value can be anything the server chooses to send. Its value is probably of interest only to the server. The
cookie's value can be changed after creation with the <code>setValue</code> method.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>name</code> - the name of the cookie</dd>
<dd><code>value</code> - the value of the cookie</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the cookie name is null or empty or contains any illegal characters (for example,
a comma, space, or semicolon) or matches a token reserved for use by the cookie protocol</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#setValue-java.lang.String-"><code>setValue(java.lang.String)</code></a>,
<a href="../../../jakarta/servlet/http/Cookie.html#setVersion-int-"><code>setVersion(int)</code></a></dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="setComment-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setComment</h4>
<pre>@Deprecated
public&nbsp;void&nbsp;setComment(java.lang.String&nbsp;purpose)</pre>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;<span class="deprecationComment">This is no longer required with RFC 6265</span></div>
<div class="block">With the adoption of support for RFC 6265, this method should no longer be used.
<p>
If called, this method has no effect.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>purpose</code> - This parameter is ignored</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#getComment--"><code>getComment()</code></a></dd>
</dl>
</li>
</ul>
<a name="getComment--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getComment</h4>
<pre>@Deprecated
public&nbsp;java.lang.String&nbsp;getComment()</pre>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;<span class="deprecationComment">This is no longer required with RFC 6265</span></div>
<div class="block">With the adoption of support for RFC 6265, this method should no longer be used.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Always <code>null</code></dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#setComment-java.lang.String-"><code>setComment(java.lang.String)</code></a></dd>
</dl>
</li>
</ul>
<a name="setDomain-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setDomain</h4>
<pre>public&nbsp;void&nbsp;setDomain(java.lang.String&nbsp;domain)</pre>
<div class="block">Specifies the domain within which this cookie should be presented.
<p>
The form of the domain name is specified by RFC 6265. A domain name begins with a dot (<code>.foo.com</code>) and
means that the cookie is visible to servers in a specified Domain Name System (DNS) zone (for example,
<code>www.foo.com</code>, but not <code>a.b.foo.com</code>). By default, cookies are only returned to the server that
sent them.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>domain</code> - the domain name within which this cookie is visible; form is according to RFC 6265</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#getDomain--"><code>getDomain()</code></a></dd>
</dl>
</li>
</ul>
<a name="getDomain--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getDomain</h4>
<pre>public&nbsp;java.lang.String&nbsp;getDomain()</pre>
<div class="block">Gets the domain name of this Cookie.
<p>
Domain names are formatted according to RFC 6265.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the domain name of this Cookie</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#setDomain-java.lang.String-"><code>setDomain(java.lang.String)</code></a></dd>
</dl>
</li>
</ul>
<a name="setMaxAge-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setMaxAge</h4>
<pre>public&nbsp;void&nbsp;setMaxAge(int&nbsp;expiry)</pre>
<div class="block">Sets the maximum age in seconds for this Cookie.
<p>
A positive value indicates that the cookie will expire after that many seconds have passed. Note that the value is
the <i>maximum</i> age when the cookie will expire, not the cookie's current age.
<p>
A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A
zero value causes the cookie to be deleted.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>expiry</code> - an integer specifying the maximum age of the cookie in seconds; if negative, means the cookie is not
stored; if zero, deletes the cookie</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#getMaxAge--"><code>getMaxAge()</code></a></dd>
</dl>
</li>
</ul>
<a name="getMaxAge--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMaxAge</h4>
<pre>public&nbsp;int&nbsp;getMaxAge()</pre>
<div class="block">Gets the maximum age in seconds of this Cookie.
<p>
By default, <code>-1</code> is returned, which indicates that the cookie will persist until browser shutdown.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an integer specifying the maximum age of the cookie in seconds; if negative, means the cookie persists until
browser shutdown</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#setMaxAge-int-"><code>setMaxAge(int)</code></a></dd>
</dl>
</li>
</ul>
<a name="setPath-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setPath</h4>
<pre>public&nbsp;void&nbsp;setPath(java.lang.String&nbsp;uri)</pre>
<div class="block">Specifies a path for the cookie to which the client should return the cookie.
<p>
The cookie is visible to all the pages in the directory you specify, and all the pages in that directory's
subdirectories. A cookie's path must include the servlet that set the cookie, for example, <i>/catalog</i>, which
makes the cookie visible to all directories on the server under <i>/catalog</i>.
<p>
Consult <a href="http://www.ietf.org/rfc/rfc6265.txt">RFC 6265</a> for more information on setting path names for
cookies.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>uri</code> - a <code>String</code> specifying a path</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#getPath--"><code>getPath()</code></a></dd>
</dl>
</li>
</ul>
<a name="getPath--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getPath</h4>
<pre>public&nbsp;java.lang.String&nbsp;getPath()</pre>
<div class="block">Returns the path on the server to which the browser returns this cookie. The cookie is visible to all subpaths on the
server.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a <code>String</code> specifying a path that contains a servlet name, for example, <i>/catalog</i></dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#setPath-java.lang.String-"><code>setPath(java.lang.String)</code></a></dd>
</dl>
</li>
</ul>
<a name="setSecure-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setSecure</h4>
<pre>public&nbsp;void&nbsp;setSecure(boolean&nbsp;flag)</pre>
<div class="block">Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
<p>
The default value is <code>false</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>flag</code> - if <code>true</code>, sends the cookie from the browser to the server only when using a secure protocol;
if <code>false</code>, sent on any protocol</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#getSecure--"><code>getSecure()</code></a></dd>
</dl>
</li>
</ul>
<a name="getSecure--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSecure</h4>
<pre>public&nbsp;boolean&nbsp;getSecure()</pre>
<div class="block">Returns <code>true</code> if the browser is sending cookies only over a secure protocol, or <code>false</code> if the
browser can send cookies using any protocol.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the browser uses a secure protocol, <code>false</code> otherwise</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#setSecure-boolean-"><code>setSecure(boolean)</code></a></dd>
</dl>
</li>
</ul>
<a name="getName--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getName</h4>
<pre>public&nbsp;java.lang.String&nbsp;getName()</pre>
<div class="block">Returns the name of the cookie. The name cannot be changed after creation.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the name of the cookie</dd>
</dl>
</li>
</ul>
<a name="setValue-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setValue</h4>
<pre>public&nbsp;void&nbsp;setValue(java.lang.String&nbsp;newValue)</pre>
<div class="block">Assigns a new value to this Cookie.
<p>
If you use a binary value, you may want to use BASE64 encoding.
<p>
With Version 0 cookies, values should not contain white space, brackets, parentheses, equals signs, commas, double
quotes, slashes, question marks, at signs, colons, and semicolons. Empty values may not behave the same way on all
browsers.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>newValue</code> - the new value of the cookie</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#getValue--"><code>getValue()</code></a></dd>
</dl>
</li>
</ul>
<a name="getValue--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getValue</h4>
<pre>public&nbsp;java.lang.String&nbsp;getValue()</pre>
<div class="block">Gets the current value of this Cookie.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the current value of this Cookie</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#setValue-java.lang.String-"><code>setValue(java.lang.String)</code></a></dd>
</dl>
</li>
</ul>
<a name="getVersion--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getVersion</h4>
<pre>@Deprecated
public&nbsp;int&nbsp;getVersion()</pre>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;<span class="deprecationComment">This is no longer required with RFC 6265</span></div>
<div class="block">With the adoption of support for RFC 6265, this method should no longer be used.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Always 0</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#setVersion-int-"><code>setVersion(int)</code></a></dd>
</dl>
</li>
</ul>
<a name="setVersion-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setVersion</h4>
<pre>@Deprecated
public&nbsp;void&nbsp;setVersion(int&nbsp;v)</pre>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;<span class="deprecationComment">This is no longer required with RFC 6265</span></div>
<div class="block">With the adoption of support for RFC 6265, this method should no longer be used.
<p>
If called, this method has no effect.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>v</code> - This parameter is ignored</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/servlet/http/Cookie.html#getVersion--"><code>getVersion()</code></a></dd>
</dl>
</li>
</ul>
<a name="clone--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>clone</h4>
<pre>public&nbsp;java.lang.Object&nbsp;clone()</pre>
<div class="block">Overrides the standard <code>java.lang.Object.clone</code> method to return a copy of this Cookie.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>clone</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
<a name="setHttpOnly-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setHttpOnly</h4>
<pre>public&nbsp;void&nbsp;setHttpOnly(boolean&nbsp;httpOnly)</pre>
<div class="block">Marks or unmarks this Cookie as <i>HttpOnly</i>.
<p>
If <tt>httpOnly</tt> is set to <tt>true</tt>, this cookie is marked as <i>HttpOnly</i>, by adding the
<tt>HttpOnly</tt> attribute to it.
<p>
<i>HttpOnly</i> cookies are not supposed to be exposed to client-side scripting code, and may therefore help mitigate
certain kinds of cross-site scripting attacks.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>httpOnly</code> - true if this cookie is to be marked as <i>HttpOnly</i>, false otherwise</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>Servlet 3.0</dd>
</dl>
</li>
</ul>
<a name="isHttpOnly--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isHttpOnly</h4>
<pre>public&nbsp;boolean&nbsp;isHttpOnly()</pre>
<div class="block">Checks whether this Cookie has been marked as <i>HttpOnly</i>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if this Cookie has been marked as <i>HttpOnly</i>, false otherwise</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>Servlet 3.0</dd>
</dl>
</li>
</ul>
<a name="setAttribute-java.lang.String-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setAttribute</h4>
<pre>public&nbsp;void&nbsp;setAttribute(java.lang.String&nbsp;name,
java.lang.String&nbsp;value)</pre>
<div class="block">Sets the value of the cookie attribute associated with the given name.
<p>
This should sync to any predefined attribute for which already a getter/setter pair exist in the current version,
except for <code>version</code>. E.g. when <code>cookie.setAttribute("domain", domain)</code> is invoked, then
<code>cookie.getDomain()</code> should return exactly that value, and vice versa.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>name</code> - the name of the cookie attribute to set the value for, case insensitive</dd>
<dd><code>value</code> - the value of the cookie attribute associated with the given name, can be <code>null</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the cookie name is null or empty or contains any illegal characters (for example,
a comma, space, or semicolon) or matches a token reserved for use by the cookie protocol.</dd>
<dd><code>java.lang.NumberFormatException</code> - if the cookie is a known field with a numerical value (eg Max-Age), but the value is
not able to be parsed.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>Servlet 6.0</dd>
</dl>
</li>
</ul>
<a name="getAttribute-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getAttribute</h4>
<pre>public&nbsp;java.lang.String&nbsp;getAttribute(java.lang.String&nbsp;name)</pre>
<div class="block">Gets the value of the cookie attribute associated with the given name.
<p>
This should sync to any predefined attribute for which already a getter/setter pair exist in the current version,
except for <code>version</code>. E.g. when <code>cookie.setAttribute("domain", domain)</code> is invoked, then
<code>cookie.getDomain()</code> should return exactly that value, and vice versa.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>name</code> - the name of the cookie attribute to get the value of, case insensitive</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the value of the cookie attribute associated with the given name</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>Servlet 6.0</dd>
</dl>
</li>
</ul>
<a name="getAttributes--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getAttributes</h4>
<pre>public&nbsp;java.util.Map&lt;java.lang.String,java.lang.String&gt;&nbsp;getAttributes()</pre>
<div class="block">Returns an unmodifiable mapping of all cookie attributes set via <a href="../../../jakarta/servlet/http/Cookie.html#setAttribute-java.lang.String-java.lang.String-"><code>setAttribute(String, String)</code></a> as well as any
predefined setter method, except for <code>version</code>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an unmodifiable mapping of all cookie attributes set via <code>setAttribute(String, String)</code> as well as
any predefined setter method, except for <code>version</code></dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>Servlet 6.0</dd>
</dl>
</li>
</ul>
<a name="hashCode--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashCode</h4>
<pre>public&nbsp;int&nbsp;hashCode()</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>hashCode</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
<a name="equals-java.lang.Object-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public&nbsp;boolean&nbsp;equals(java.lang.Object&nbsp;obj)</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>equals</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
<a name="toString--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>toString</h4>
<pre>public&nbsp;java.lang.String&nbsp;toString()</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev&nbsp;Class</li>
<li><a href="../../../jakarta/servlet/http/HttpFilter.html" title="class in jakarta.servlet.http"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?jakarta/servlet/http/Cookie.html" target="_top">Frames</a></li>
<li><a href="Cookie.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>