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 trying 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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top