开发者

cookie tutorial problem

开发者 https://www.devze.com 2023-02-10 09:27 出处:网络
http://www.hccp.org/java-net-cookie-how-to.html According to this link I was trying to create cookie and send cookie to enter in a cookie site. But it is not working. Is there is any problem in that.

http://www.hccp.org/java-net-cookie-how-to.html

According to this link I was trying to create cookie and send cookie to enter in a cookie site. But it is not working. Is there is any problem in that. I have some confusion on the method setRequestProperty of URLConnection. I don't understand what are they t开发者_开发技巧rying to send by passing "Cookie"? Is it only a string or name or value??


urlConn.setRequestProperty("Cookie", myCookie);

"Cookie" in this case is a way to tell the setRequestProperty method that the argument (which is really just a String) should be treated as a cookie.

setRequestProperty may be more useful for many kinds of properties, but addRequestProperty would be more useful for cookies, because you can have multiple cookies per request. The properties are specified in RFC 2068 -- read especially section 14.

0

精彩评论

暂无评论...
验证码 换一张
取 消