views:

136

answers:

1

I cannot see this behavior in JBoss 4.2.3. If I try to call addCookie() on HttpServletResponse and my cookie value has accented characters in it (ex. ç) I get this exception: java.lang.IllegalArgumentException: Control character in cookie value, consider BASE64 encoding your value

Does anyone know what change in JBoss 5.1.0 could be causing these problems?

+2  A: 

Apparently they fixed a bug so that the cookie name now finally conforms the RFC2109.

Also see the javax.servlet.http.Cookie API specification:

The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation.

The c with cedille ç is not an ASCII character.


Update: sorry, the problem concerns the cookie value. This is then related to this Tomcat bugfix (JBoss uses Tomcat under the hoods). This should be workaroundable by setting the cookie version as follows:

cookie.setVersion(1);

The ç is not a valid character for the cookie value according the old Netscape specification, but it is according the newer RFC2109 specification. With the Cookie#setVersion() you can toggle between them.

BalusC
The question asks about cookie values, not the cookie name.
Photodeus
@Photodeus: I see. I updated the answer. Thank you for retification.
BalusC
I've solved the problem by base64 encoding certain cookie values (and decoding when read). I've tried setting the cookie version to 1 but that did not solve the problem. Also, from what I have read, setting cookie version to 1 breaks in IE7. Does anyone know what is different in JBoss 5.1.0 because in 4.2.3 I was able to pass values with accents with no problems.