📄 cookie.html
字号:
<A NAME="setComment(java.lang.String)"><!-- --></A><H3>setComment</H3><PRE>public void <B>setComment</B>(java.lang.String purpose)</PRE><DL><DD>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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>purpose</CODE> - a <code>String</code> specifying the comment to display to the user<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#getComment()"><CODE>getComment()</CODE></A></DL></DD></DL><HR><A NAME="getComment()"><!-- --></A><H3>getComment</H3><PRE>public java.lang.String <B>getComment</B>()</PRE><DL><DD>Returns the comment describing the purpose of this cookie, or <code>null</code> if the cookie has no comment.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> containing the comment, or <code>null</code> if none<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#setComment(java.lang.String)"><CODE>setComment(java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="setDomain(java.lang.String)"><!-- --></A><H3>setDomain</H3><PRE>public void <B>setDomain</B>(java.lang.String pattern)</PRE><DL><DD>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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>pattern</CODE> - a <code>String</code> containing the domain name within which this cookie is visible; form is according to RFC 2109<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#getDomain()"><CODE>getDomain()</CODE></A></DL></DD></DL><HR><A NAME="getDomain()"><!-- --></A><H3>getDomain</H3><PRE>public java.lang.String <B>getDomain</B>()</PRE><DL><DD>Returns the domain name set for this cookie. The form of the domain name is set by RFC 2109.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> containing the domain name<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#setDomain(java.lang.String)"><CODE>setDomain(java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="setMaxAge(int)"><!-- --></A><H3>setMaxAge</H3><PRE>public void <B>setMaxAge</B>(int expiry)</PRE><DL><DD>Sets the maximum age of the cookie in seconds. <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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><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<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#getMaxAge()"><CODE>getMaxAge()</CODE></A></DL></DD></DL><HR><A NAME="getMaxAge()"><!-- --></A><H3>getMaxAge</H3><PRE>public int <B>getMaxAge</B>()</PRE><DL><DD>Returns the maximum age of the cookie, specified in seconds, By default, <code>-1</code> indicating the cookie will persist until browser shutdown.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>an integer specifying the maximum age of the cookie in seconds; if negative, means the cookie persists until browser shutdown<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#setMaxAge(int)"><CODE>setMaxAge(int)</CODE></A></DL></DD></DL><HR><A NAME="setPath(java.lang.String)"><!-- --></A><H3>setPath</H3><PRE>public void <B>setPath</B>(java.lang.String uri)</PRE><DL><DD>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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>uri</CODE> - a <code>String</code> specifying a path<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#getPath()"><CODE>getPath()</CODE></A></DL></DD></DL><HR><A NAME="getPath()"><!-- --></A><H3>getPath</H3><PRE>public java.lang.String <B>getPath</B>()</PRE><DL><DD>Returns the path on the server to which the browser returns this cookie. The cookie is visible to all subpaths on the server.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> specifying a path that contains a servlet name, for example, <i>/catalog</i><DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#setPath(java.lang.String)"><CODE>setPath(java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="setSecure(boolean)"><!-- --></A><H3>setSecure</H3><PRE>public void <B>setSecure</B>(boolean flag)</PRE><DL><DD>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>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>flag</CODE> - if <code>true</code>, sends the cookie from the browser to the server using only when using a secure protocol; if <code>false</code>, sent on any protocol<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#getSecure()"><CODE>getSecure()</CODE></A></DL></DD></DL><HR><A NAME="getSecure()"><!-- --></A><H3>getSecure</H3><PRE>public boolean <B>getSecure</B>()</PRE><DL><DD>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.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if the browser uses a secure protocol; otherwise, <code>true</code><DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#setSecure(boolean)"><CODE>setSecure(boolean)</CODE></A></DL></DD></DL><HR><A NAME="getName()"><!-- --></A><H3>getName</H3><PRE>public java.lang.String <B>getName</B>()</PRE><DL><DD>Returns the name of the cookie. The name cannot be changed after creation.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> specifying the cookie's name</DL></DD></DL><HR><A NAME="setValue(java.lang.String)"><!-- --></A><H3>setValue</H3><PRE>public void <B>setValue</B>(java.lang.String newValue)</PRE><DL><DD>Assigns a new value to a cookie after the cookie is created. 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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newValue</CODE> - a <code>String</code> specifying the new value<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#getValue()"><CODE>getValue()</CODE></A>, <A HREF="../../../javax/servlet/http/Cookie.html"><CODE>Cookie</CODE></A></DL></DD></DL><HR><A NAME="getValue()"><!-- --></A><H3>getValue</H3><PRE>public java.lang.String <B>getValue</B>()</PRE><DL><DD>Returns the value of the cookie.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> containing the cookie's present value<DT><B>See Also: </B><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"><CODE>Cookie</CODE></A></DL></DD></DL><HR><A NAME="getVersion()"><!-- --></A><H3>getVersion</H3><PRE>public int <B>getVersion</B>()</PRE><DL><DD>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.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>0 if the cookie complies with the original Netscape specification; 1 if the cookie complies with RFC 2109<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#setVersion(int)"><CODE>setVersion(int)</CODE></A></DL></DD></DL><HR><A NAME="setVersion(int)"><!-- --></A><H3>setVersion</H3><PRE>public void <B>setVersion</B>(int v)</PRE><DL><DD>Sets the version of the cookie protocol this cookie complies with. 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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>v</CODE> - 0 if the cookie should comply with the original Netscape specification; 1 if the cookie should comply with RFC 2109<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/Cookie.html#getVersion()"><CODE>getVersion()</CODE></A></DL></DD></DL><HR><A NAME="clone()"><!-- --></A><H3>clone</H3><PRE>public java.lang.Object <B>clone</B>()</PRE><DL><DD>Overrides the standard <code>java.lang.Object.clone</code> method to return a copy of this cookie.<DD><DL><DT><B>Overrides:</B><DD>clone in class java.lang.Object</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../../javax/servlet/http/HttpServlet.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Cookie.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -