Jean-Christophe Collet's Weblog
Jean-Christophe Collet's Weblog

20090401 Wednesday April 01, 2009

The trouble with Cookies

HTTP Cookie support was introduced in JDK 5 with the CookieHandler API, then significantly extended in JDK 6 with HttpCookie, CookieManager, CookiePolicy and CookieStore.

However a number of bugs (many due to the fact that the implementation followed the RFCs specs more closely than your average browser or server) and missing features made it less than perfect and somewhat of a pain to work with what is really out "there".

The good news is that these have been fixed in JDK 7 and I wanted to take some time to outline some of these.

First and foremost, CR 6644726 was a bucket for quite a few (7 to be exact) of these, including some domain matching problems. Also noticeable is CR 6641309 which deals with the separator used when sending multiple cookies in one header. CR 6641315 was about parsing expiration dates for Netscape style cookies. And CR 6790677 pointed out that unknown cookie attributes should be ignored instead of generating an error, while CR 6692802 added support for the HttpOnly attribute. Finally CR 6791927 complained about Locale issue when parsing expiration dates.

Now that all these bugs have been fixed, I have been able to test the Cookie API with various sites making heavy use of cookies (Google mail, Google maps, Yahoo, Amazon, etc...), so I'm confident we do have a reasonably functional cookie API in JDK 7.

In (near) future posts, I will give some code examples of its uses and go over some of tips and tricks.

Don't forget JavaOne is June 2nd - June 5th!

(2009-04-01 04:43:35.0) Permalink


archives
links
referers