Java HttpCookie parse() MethodThe parse(String header) method of HttpCookie class is invoked to construct the cookies from set-cookie or set-cookie2 header string. SyntaxParameterThe above method requires only ne parameter:
ReturnThe above method is used to return a List of cookies which are parsed from header line string. ThrowsIllegalArgumentException - if the header string breaks the cookie specification?s syntax or the given cookie name contains some illegal characters. NullPointerException - if the header string is a null. Example 1Test it NowOutput: Exception in thread "main" java.lang.NullPointerException at java.net.HttpCookie.guessCookieVersion(Unknown Source) at java.net.HttpCookie.parse(Unknown Source) at java.net.HttpCookie.parse(Unknown Source) at javatpoint.JavaHttpCookieParseExample1.main(JavaHttpCookieParseExample1.java:10) Example 2Test it NowOutput: Exception in thread "main" java.lang.IllegalArgumentException: Invalid cookie name-value pair at java.net.HttpCookie.parseInternal(Unknown Source) at java.net.HttpCookie.parse(Unknown Source) at java.net.HttpCookie.parse(Unknown Source) at javatpoint.JavaHttpCookieParseExample2.main(JavaHttpCookieParseExample2.java:8) Next TopicsetComment() Method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India