| <!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> |
| </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":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10}; |
| var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete 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 Class</li> |
| <li><a href="../../../javax/servlet/http/HttpFilter.html" title="class in javax.servlet.http"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../index.html?javax/servlet/http/Cookie.html" target="_top">Frames</a></li> |
| <li><a href="Cookie.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../allclasses-noframe.html">All 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: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </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">javax.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>javax.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="../../../javax/servlet/http/HttpServletResponse.html#addCookie-javax.servlet.http.Cookie-"><code>HttpServletResponse.addCookie(javax.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="../../../javax/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 both the Version 0 (by Netscape) and Version 1 |
| (by RFC 2109) cookie specifications. By default, cookies are |
| created using Version 0 to ensure the best interoperability.</div> |
| <dl> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../serialized-form.html#javax.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"> </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="../../../javax/servlet/http/Cookie.html#Cookie-java.lang.String-java.lang.String-">Cookie</a></span>(java.lang.String name, |
| java.lang.String 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"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </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="../../../javax/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>java.lang.String</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#getComment--">getComment</a></span>()</code> |
| <div class="block">Returns the comment describing the purpose of this cookie, or |
| <code>null</code> if the cookie has no comment.</div> |
| </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="../../../javax/servlet/http/Cookie.html#getDomain--">getDomain</a></span>()</code> |
| <div class="block">Gets the domain name of this Cookie.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code>int</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/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="i4" class="altColor"> |
| <td class="colFirst"><code>java.lang.String</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#getName--">getName</a></span>()</code> |
| <div class="block">Returns the name of the cookie.</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="../../../javax/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="i6" class="altColor"> |
| <td class="colFirst"><code>boolean</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/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="i7" class="rowColor"> |
| <td class="colFirst"><code>java.lang.String</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#getValue--">getValue</a></span>()</code> |
| <div class="block">Gets the current value of this Cookie.</div> |
| </td> |
| </tr> |
| <tr id="i8" class="altColor"> |
| <td class="colFirst"><code>int</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#getVersion--">getVersion</a></span>()</code> |
| <div class="block">Returns the version of the protocol this cookie complies |
| with.</div> |
| </td> |
| </tr> |
| <tr id="i9" class="rowColor"> |
| <td class="colFirst"><code>boolean</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/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="i10" class="altColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#setComment-java.lang.String-">setComment</a></span>(java.lang.String purpose)</code> |
| <div class="block">Specifies a comment that describes a cookie's purpose.</div> |
| </td> |
| </tr> |
| <tr id="i11" class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#setDomain-java.lang.String-">setDomain</a></span>(java.lang.String domain)</code> |
| <div class="block">Specifies the domain within which this cookie should be presented.</div> |
| </td> |
| </tr> |
| <tr id="i12" class="altColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#setHttpOnly-boolean-">setHttpOnly</a></span>(boolean isHttpOnly)</code> |
| <div class="block">Marks or unmarks this Cookie as <i>HttpOnly</i>.</div> |
| </td> |
| </tr> |
| <tr id="i13" class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#setMaxAge-int-">setMaxAge</a></span>(int expiry)</code> |
| <div class="block">Sets the maximum age in seconds for this Cookie.</div> |
| </td> |
| </tr> |
| <tr id="i14" class="altColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#setPath-java.lang.String-">setPath</a></span>(java.lang.String uri)</code> |
| <div class="block">Specifies a path for the cookie |
| to which the client should return the cookie.</div> |
| </td> |
| </tr> |
| <tr id="i15" class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#setSecure-boolean-">setSecure</a></span>(boolean 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="i16" class="altColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#setValue-java.lang.String-">setValue</a></span>(java.lang.String newValue)</code> |
| <div class="block">Assigns a new value to this Cookie.</div> |
| </td> |
| </tr> |
| <tr id="i17" class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/servlet/http/Cookie.html#setVersion-int-">setVersion</a></span>(int v)</code> |
| <div class="block">Sets the version of the cookie protocol that this Cookie complies |
| with.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.Object</h3> |
| <code>equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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 Cookie(java.lang.String name, |
| java.lang.String value)</pre> |
| <div class="block">Constructs a cookie with the specified name and value. |
| |
| <p>The name must conform to RFC 2109. 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. |
| |
| <p>By default, cookies are created according to the Netscape |
| cookie specification. The version can be changed with the |
| <code>setVersion</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="../../../javax/servlet/http/Cookie.html#setValue-java.lang.String-"><code>setValue(java.lang.String)</code></a>, |
| <a href="../../../javax/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>public void setComment(java.lang.String purpose)</pre> |
| <div class="block">Specifies a comment that describes a cookie's purpose. |
| The comment is useful if the browser presents the cookie |
| to the user. Comments |
| are not supported by Netscape Version 0 cookies.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>purpose</code> - a <code>String</code> specifying the comment |
| to display to the user</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../javax/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>public java.lang.String getComment()</pre> |
| <div class="block">Returns the comment describing the purpose of this cookie, or |
| <code>null</code> if the cookie has no comment.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the comment of the cookie, or <code>null</code> if unspecified</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../javax/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 void setDomain(java.lang.String 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 2109. 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 2109</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../javax/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 java.lang.String getDomain()</pre> |
| <div class="block">Gets the domain name of this Cookie. |
| |
| <p>Domain names are formatted according to RFC 2109.</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="../../../javax/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 void setMaxAge(int 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="../../../javax/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 int 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="../../../javax/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 void setPath(java.lang.String 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 RFC 2109 (available on the Internet) 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="../../../javax/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 java.lang.String 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="../../../javax/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 void setSecure(boolean 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="../../../javax/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 boolean 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="../../../javax/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 java.lang.String 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 void setValue(java.lang.String 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="../../../javax/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 java.lang.String 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="../../../javax/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>public int getVersion()</pre> |
| <div class="block">Returns the version of the protocol this cookie complies |
| with. Version 1 complies with RFC 2109, |
| and version 0 complies with the original |
| cookie specification drafted by Netscape. Cookies provided |
| by a browser use and identify the browser's cookie version.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>0 if the cookie complies with the |
| original Netscape specification; 1 |
| if the cookie complies with RFC 2109</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../javax/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>public void setVersion(int v)</pre> |
| <div class="block">Sets the version of the cookie protocol that this Cookie complies |
| with. |
| |
| <p>Version 0 complies with the original Netscape cookie |
| specification. Version 1 complies with RFC 2109. |
| |
| <p>Since RFC 2109 is still somewhat new, consider |
| version 1 as experimental; do not use it yet on production sites.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>v</code> - 0 if the cookie should comply with the original Netscape |
| specification; 1 if the cookie should comply with RFC 2109</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../javax/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 java.lang.Object 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> in class <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 void setHttpOnly(boolean isHttpOnly)</pre> |
| <div class="block">Marks or unmarks this Cookie as <i>HttpOnly</i>. |
| |
| <p>If <tt>isHttpOnly</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>isHttpOnly</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="blockListLast"> |
| <li class="blockList"> |
| <h4>isHttpOnly</h4> |
| <pre>public boolean 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> |
| </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 Class</li> |
| <li><a href="../../../javax/servlet/http/HttpFilter.html" title="class in javax.servlet.http"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../index.html?javax/servlet/http/Cookie.html" target="_top">Frames</a></li> |
| <li><a href="Cookie.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../allclasses-noframe.html">All 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: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |