Bug 33961 - session cookies for context containing '~' do not work
session cookies for context containing '~' do not work
Status: RESOLVED FIXED
Product: Tomcat 5
Classification: Unclassified
Component: Catalina
5.5.7
All All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
http://www.hostingjava.it
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-03-11 13:21 UTC by xamul
Modified: 2006-11-15 05:18 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xamul 2005-03-11 13:21:46 UTC
I you create an application containing '~' character cookies do non work
properly,  because the url set in the cookie encodes the ~ character in
urlencoded format.
For example if your context name is 
/~luigi
The cookies send back to the client are with a path:
/%74luigi

This makes the server unable to recognize the sessionid, like cookies were disabled.
Comment 1 Remy Maucherat 2005-03-24 18:20:49 UTC
Fixed.
Comment 2 Steffen Spahr 2006-11-15 05:11:43 UTC
Hi,

I am using Apache Tomcat/5.5.17.

With this version I got the same result as described in the bug-report.

Is it realy fixed?

The Cookie.getPath() and Cookie.getDomain() returns always 'null'.


My example program:

package test;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CookieAnzeige extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// Returns a writer to write to the browser
		PrintWriter out = response.getWriter();

		// Writes the string to the browser.
		out.println("Anzeige und Setzen von Cookies:");

		Cookie[] cookies = request.getCookies();
		if (cookies == null)
			out.println("Kein Cookie gesetzt!");
		else {
			for (int i = 0; i < cookies.length; i++) {
				String cookieName = cookies[i].getName();
				out.println("Cookie " + cookieName + " hat den Wert "
						+ cookies[i].getValue() + " Pfad: "
						+ cookies[i].getPath() + " Domain: "
						+ cookies[i].getDomain());
			}
		}

		Cookie Versicherungsnehmer = new Cookie("Versicherungsnehmer", "123456");
		Versicherungsnehmer.setPath("/");
		response.addCookie(Versicherungsnehmer);

		out.close();
	}
}


The result:

Anzeige und Setzen von Cookies:

Cookie JSESSIONID hat den Wert A08AE263E7D9854C649BEA65CDE5056A Pfad: null
Domain: null

Cookie Versicherungsnehmer hat den Wert 123456 Pfad: null Domain: null 
Comment 3 Steffen Spahr 2006-11-15 05:18:25 UTC
Sorry,

my mistake !!! 

The correct Bug-Report-number is ASF Bugzilla Bug 16474.