沒啥好說的,Servlet規範裡的東西,英文看着不爽就翻譯了。有不恰當的地方,還望高手指正。
<a></a>
<b>Class</b>
<dl></dl>
<dt>extends java.lang.Object</dt>
<dt>implements java.lang.Cloneable</dt>
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. 建立一個cookie,一個小量資訊通過Servlet發送給Web浏覽器,通過浏覽器儲存,以後再從浏覽器發送給伺服器。一個cookie的值能唯一識别一個用戶端,是以cookie常用于session的管理。
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. 一個cookie有一個名字和一個值和一些可選擇的屬性例如注釋、路徑、域、最大有效時間、版本号等。一些浏覽器在處理可選項時有bug,是以應保守使用以提高sevlet的互動性。
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. Cookie影響每一個使用它的web頁。 (......)
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. 這個類同時支援版本0和版本1的cookie規範。預設情況下,cookie使用版本0來建立以確定最好的互動性。
<b>Constructor Summary</b>
Constructs a cookie with a specified name and value. 使用指定的名稱和值建構一個cookie。
<b>Method Summary</b>
java.lang.Object
Overrides the standard <code>java.lang.Object.clone</code> method to return a copy of this cookie. 傳回cookie克隆的副本,這個方法覆寫了<code>java.lang.Object.clone</code>()方法。
java.lang.String
Returns the comment describing the purpose of this cookie, or <code>null</code> if the cookie has no comment.傳回一個描述cookie用途的注釋,如果沒有注釋,則傳回null。
Returns the domain name set for this cookie.傳回一個cookie域名。(域名指定cookie在哪個域中有效,例如:Domain=.blog.51cto.com)
int
Returns the maximum age of the cookie, specified in seconds, By default, <code>-1</code> indicating the cookie will persist until browser shutdown. 傳回cookie在用戶端最大的有效時間,以秒為機關。預設情況下為-1,表示cookie将一直有效直到浏覽器關閉。
Returns the name of the cookie.傳回cookie的名字。
Returns the path on the server to which the browser returns this cookie.傳回cookie對伺服器上哪個url有效。
boolean
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. 如果浏覽器僅僅安全協定下發送cookie則傳回true。浏覽器能使用任何協定發送cookie則傳回fasle。
Returns the value of the cookie. 傳回cookie的值。
Returns the version of the protocol this cookie complies with.傳回cookie内容所遵循的版本。(目前隻有值為1時可用)。
void
Specifies a comment that describes a cookie's purpose.設定描述cookie用途的注釋。
Specifies the domain within which this cookie should be presented.設定cookie在哪一個域中使用。
Sets the maximum age of the cookie in seconds.設定cookie最大的有效時間。
Specifies a path for the cookie to which the client should return the cookie.設定cookie的有效路徑。
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.設定是否使用安全協定如HTTPS或SSL等發送cookie。
Assigns a new value to a cookie after the cookie is created. 給一個cookie重新指定一個新值。
Sets the version of the cookie protocol this cookie complies with.設定cookie使用的協定版本。
<b>Methods inherited from class java.lang.Object</b>
<code>equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code>
<b>Constructor Detail</b>
<dd>Constructs a cookie with a specified name and value. 使用指定的名稱和值建立一個cookie。</dd>
The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation. 這個名稱必須遵循RFC 2109的規範。這意味着它僅僅能包含ASCII碼字元,并且不能包含逗号,分号,或者空格,或者以$開頭的字元串,cookie的名字在建立後就不能再改變了。
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. 這個值可以發送給任何的伺服器,但是僅對某個伺服器有作用。這個值在建立後可以通過<code>setValue</code>方法來改變。
By default, cookies are created according to the Netscape cookie specification. The version can be changed with the <code>setVersion</code> method. 預設情況下,依照Netscape cookie規範來建立,版本可以通過<code>setVersion</code>來改變。
<dd><dl></dl></dd>
<dt><b>Parameters:</b></dt>
<dd></dd>
<code>name</code> - a <code>String</code> specifying the name of the cookie 一個指定cookie名字的字元串。
<code>value</code> - a <code>String</code> specifying the value of the cookie 一個指定cookie值的字元串。
<dt><b>Throws:</b></dt>
<dd>java.lang.IllegalArgumentException - if the cookie name contains illegal characters (for example, a comma, space, or semicolon) or it is one of the tokens reserved for use by the cookie protocol</dd>
<dt><b>See Also:</b></dt>
<b>Method Detail</b>
<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. 設定用來描述cookie目的的注釋,如果浏覽器将這個cookie給一個使用者,這個資訊将很有用。注釋不支援通過Netscape版本0的cookie。</dd>
<code>purpose</code> - a <code>String</code> specifying the comment to display to the user 一個顯示給使用者的字元串注釋。
<dd>Returns the comment describing the purpose of this cookie, or <code>null</code> if the cookie has no comment.傳回一個描述cookie意圖的注釋,當沒有注釋的時候傳回null。</dd>
<dt><b>Returns:</b></dt>
<dd>a <code>String</code> containing the comment, or <code>null</code> if none</dd>
<dd>Specifies the domain within which this cookie should be presented. 指定cookie将在哪個域裡面有效。</dd>
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>[url]www.foo.com[/url]</code>, but not <code>a.b.foo.com</code>). By default, cookies are only returned to the server that sent them. 如果域名使用RFC 2109規範,那麼名字應該以點開始 (<code>.foo.com</code>),并且意味着這個cookie在指定的域名系統(DNS)下是有效的,比如(<code>[url]www.foo.com[/url]</code>,但不是<code>a.b.foo.com</code>)。預設情況下,cookie僅能傳回給發送他們的伺服器。
<code>pattern</code> - a <code>String</code> containing the domain name within which this cookie is visible; form is according to RFC 2109
<dd>Returns the domain name set for this cookie. The form of the domain name is set by RFC 2109.傳回一個cookie域名。域名使用RFC 2109規範。</dd>
<dd>a <code>String</code> containing the domain name</dd>
<dd>Sets the maximum age of the cookie in seconds. 以秒為機關設定cookie最大的有效時間。</dd>
A positive value indicates that the cookie will expire after that many seconds have passed. Note that the value is the maximum age when the cookie will expire, not the cookie's current age. 一個明确值指定cookie将在多少秒過後失效。注意,這個值是cookie有效期滿的最大值,不是目前cookie的存在時間。
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.一個負值意味着cookie不連續存儲,并且在浏覽器推出的時候删除。一個0值将導緻cookie被删除。
<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>Returns the maximum age of the cookie, specified in seconds, By default, <code>-1</code> indicating the cookie will persist until browser shutdown. 傳回cookie最大有效期,預設情況下,-1表示cookie将一直有效,直到浏覽器關閉。</dd>
<dd>an integer specifying the maximum age of the cookie in seconds; if negative, means the cookie persists until browser shutdown</dd>
<dd>Specifies a path for the cookie to which the client should return the cookie. 為應該傳回cookie的用戶端cookie指定一個路徑。</dd>
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, /catalog, which makes the cookie visible to all directories on the server under /catalog. 這個cookie将對指定目錄中及其子目錄所有的頁可見。一個cookie路徑必須包含設定它的那個servlet,例如,/catalog,這使得cookie在/catalog下可見。
Consult RFC 2109 (available on the Internet) for more information on setting path names for cookies.檢視RFC 2109規範,有更多關于設定路徑名的資訊。
<code>uri</code> - a <code>String</code> specifying a path
<dd>Returns the path on the server to which the browser returns this cookie. The cookie is visible to all subpaths on the server.傳回一個cookie傳回伺服器的路徑,并且這個cookie對伺服器上該路徑下所有的子路徑有效。</dd>
<dd>a <code>String</code> specifying a path that contains a servlet name, for example, /catalog</dd>
<dd>Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL. 指定浏覽器将使用安全協定(例如,HTTPS 或 SSL)發送cookie。</dd>
The default value is <code>false</code>. 預設值是false。
<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>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. 如果浏覽器僅僅安全協定下發送cookie則傳回true。浏覽器能使用任何協定發送cookie則傳回fasle。</dd>
<code>true</code> if the browser uses a secure protocol; otherwise, <code>true</code>
<dd>Returns the name of the cookie. The name cannot be changed after creation. 傳回cookie的名字。在建立後名字不能改變。</dd>
<dd>a <code>String</code> specifying the cookie's name</dd>
<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. 為一個已經建立好的cookie指定一個新值,如果使用二進制值,則可能要使用BASE64編碼。</dd>
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. 在版本0cookie裡,不能包含空格、括号、圓括号、等号、逗号、雙引号、問号、冒号等等。空值一樣可以在所有浏覽器上工作。
<code>newValue</code> - a <code>String</code> specifying the new value
<dd>Returns the value of the cookie.傳回一個cookie的值。</dd>
<dd>a <code>String</code> containing the cookie's present value</dd>
<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. 傳回cookie遵循的版本。版本1遵循RFC 2109規範,版本0遵循老的Netscape制定的cookie規範。cookie隻能通過浏覽器使用來辨別,并且認出一個cookie的版本。</dd>
<dd>0 if the cookie complies with the original Netscape specification; 1 if the cookie complies with RFC 2109</dd>
<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. 設定cookie所遵循的本版。版本0遵循Netscape公司的cookie規範,版本1遵循RFC 2109規範。</dd>
Since RFC 2109 is still somewhat new, consider version 1 as experimental; do not use it yet on production sites.由于RFC 2109是較新的規範,認為版本1是一個實驗規範:不能适用于生産環境。
<code>v</code> - 0 if the cookie should comply with the original Netscape specification; 1 if the cookie should comply with RFC 2109
<dd>Overrides the standard <code>java.lang.Object.clone</code> method to return a copy of this cookie. 傳回cookie克隆的副本,這個方法覆寫了<code>java.lang.Object.clone</code>()方法。</dd>
<dt><b>Overrides:</b></dt>
<dd>clone in class java.lang.Object</dd>
本文轉自 leizhimin 51CTO部落格,原文連結:http://blog.51cto.com/lavasoft/78163,如需轉載請自行聯系原作者