1.void setComment(java.lang.String purpose)
Specifies a comment that describes a cookie's purpose.
2.void setDomain(java.lang.String domain)
Specifies the domain within which this cookie should be presented.
3.void setHttpOnly(boolean isHttpOnly)
Marks or unmarks this Cookie as HttpOnly.
4.void setMaxAge(int expiry)
Sets the maximum age in seconds for this Cookie. 在将cookie对象发送到浏览器端保存时,需要指定cookie的有效期,有效期已过,浏览器就会删除该cookie对象。
注:cookie的有效期设置如下
1)属性是按秒为单位记录的,使用正整数。
2)负表示该cookie的生存期是当前浏览器会话
3)零表示立即删除该cookie
4)如果不设置cookie的有效期,就不能在硬盘上存储cookie的信息,一旦浏览器关闭,cookie信息就消失。
5.void setPath(java.lang.String uri)
Specifies a path for the cookie to which the client should return the cookie.
6.void setSecure(boolean flag)
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
注:Http和https简要介绍
1.http
HTTP协议是基于tcp/ip协议族的;HTTP协议永远都是客户端发起请求,服务器响应请求;HTTP协议是一个无状态的协议;HTTP协议(V1.1)默认是长连接的
2.HTTP协议的工作流程

3.http请求
GET / HTTP/1.1
Host: xxx.10086.cn
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10
Accept: text/html,application/xhtmlxml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
If-Modified-Since: Mon, 25 May 2009 03:19:18 GMT
Cookie: T_FPCid=227a89d92136543e4da1299123152907
4.HTTP应答
HTTP/1.1 200 OK
Cache-Control: private, max-age=30
Content-Type: text/html; charset=utf-8
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-36808-17.html
勾践
王路平
美爆了
俄国重心在欧洲所以放弃在华利益
这文章也真是醉了