Hey,
I am facing a very weird problem when trying to read a cookie who's
value has a colon.
The issue faced is that when a request is routed from a jsp the cookie
versions are messed up. But when the servlet is directly called the
versions are maintained as expected . Ive written a small test having an
index.jsp and a cookieservlet. When a call goes to index.jsp ,it simply
forwards the request to CookieServlet which then sets a value
(test:test:test) to a cookie. Ive explained in detail below.
*Please note* :For the request and response traces i've used fiddler and
the code is attached in this mail for reference.The following issue
happens very randomly on the browser and every single time when using
JMeter.
Please check and let me know if this is a bug with Tomcat?
*Issue Faced in Detail:*
When a call directly goes to index.jsp . You notice in the second
request the cookie is sent as version 0. Now in the application when I
try and read the value of the cookie it prints out the value as just
test and everything after the colon is truncated.
A) First Request
//Raw Request
GET http://localhost:8081/index.jsp HTTP/1.1
Connection: close
User-Agent: Java/1.6.0_22
Host: localhost:8081
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
// Raw Response
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=DCA96AF717EBF0D2506A959CE415FA70; Path=/
Set-Cookie: testingcolon="test:test:test"; Version=1
Content-Type: text/html;charset=UTF-8
Content-Length: 0
Date: Tue, 08 Feb 2011 18:15:13 GMT
Connection: close
B)Next Request
//Raw Request
GET http://localhost:8081/index.jsp HTTP/1.1
Connection: close
Cookie: $Version=0;
JSESSIONID=DCA96AF717EBF0D2506A959CE415FA70; $Path=/;
testingcolon=test:test:test
User-Agent: Java/1.6.0_22
Host: localhost:8081
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
//Raw Response
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: testingcolon="test:test:test"; Version=1
Content-Type: text/html;charset=UTF-8
Content-Length: 90
Date: Tue, 08 Feb 2011 18:15:13 GMT
Connection: close
Name: JSESSIONID Value: DCA96AF717EBF0D2506A959CE415FA70
Name: testingcolon Value: test
When a call directly goes to CookieServlet.Notice in the second request
the cookie is sent as version 1. Now in the application when I try and
read the value of the cookie its prints out the value as expected which
is test:test:test
A) First Request
// Raw Request
GET http://localhost:8081/servlet/CookieServlet HTTP/1.1
Connection: close
User-Agent: Java/1.6.0_22
Host: localhost:8081
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
// Raw Response
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: testingcolon="test:test:test"; Version=1
Content-Length: 0
Date: Tue, 08 Feb 2011 18:16:27 GMT
Connection: close
B) Next Request
// Raw Request
GET http://localhost:8081/servlet/CookieServlet HTTP/1.1
Connection: close
Cookie: $Version="1"; testingcolon="test:test:test"
User-Agent: Java/1.6.0_22
Host: localhost:8081
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
//Raw Response
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: testingcolon="test:test:test"; Version=1
Content-Length: 42
Date: Tue, 08 Feb 2011 18:16:27 GMT
Connection: close
Name: testingcolon Value: test:test:test
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org