For what it's worth, I tested this with Tomcat and they appear to handle it fine. I included the requests headers below to show that the JSESSIONID is in fact being sent after the test cookie. Here is the full JSP that I am using to test with:
<%@ page import="java.io.,java.util.,java.net.*" session="true"%>
<html>
<head>
</head>
<body>
<%
boolean found = false;
Cookie[] cks = request.getCookies();
if( cks != null ) {
for( int i=0; i<cks.length; i++ )
{
%>Cookie: <%= cks[i].getName() %><br/>
Value: <%= cks[i].getValue() %><br/><br/><%
if( "cookie1".equalsIgnoreCase( cks[i].getName() ) ) found = true;
}
}
if( ! found ) {
String str = "cookie1=%c2%a8%c3%acR%13%7b%e2%82%acX%c3%9a%c3%9b%3d%22%cb%9c%c3%ae3r%c3%b5%c3%8d%c5%bd'%c2%b8%e2%82%ac%1f%e2%84%a2P;";
response.setHeader( "Set-Cookie", str );
}
%>
</body>
</html>
This is the raw request that is sent to the JSP (after the cookie is set):
GET /init.jsp HTTP/1.1
Accept: /
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Host: 192.168.1.27:8080
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: cookie1=%c2%a8%c3%acR%13%7b%e2%82%acX%c3%9a%c3%9b%3d%22%cb%9c%c3%ae3r%c3%b5%c3%8d%c5%bd'%c2%b8%e2%82%ac%1f%e2%84%a2P; JSESSIONID=BCEA3F599B082CE0BD67830232A5C26A
For completeness (not that it matters other than to show it is handled by Tomcat), here is the response to the above request:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 278
Date: Wed, 22 Nov 2006 21:34:01 GMT
Here is the info displayed in the browser:
Cookie: cookie1
Value: %c2%a8%c3%acR%13%7b%e2%82%acX%c3%9a%c3%9b%3d%22%cb%9c%c3%ae3r%c3%b5%c3%8d%c5%bd'%c2%b8%e2%82%ac%1f%e2%84%a2P
Cookie: JSESSIONID
Value: BCEA3F599B082CE0BD67830232A5C26A
quotes in cookies are a very problematic matter. the specs differ in their implementation and it also plays to the issue of version 0 vs version 1 cookies and
how browsers handle them etc. etc.
so ideally it would be best to avoid such special characters in your cookies.
Having said that, I think Jetty could probably do better with parsing a single single quote - or at least encode it.
Do you know if the %xx encoding in that string is being done by Jetty or by their application?