tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James, Stuart" <>
Subject cookies,
Date Mon, 05 Nov 2001 17:24:11 GMT

I am currently upgrading my web application from tomcat 3.x to tomcat 4.x.

To extract cookies I have a helper function,

    public static String getCookie( javax.servlet.http.HttpServletRequest
request,  String strName, String strDefault)
        javax.servlet.http.Cookie cookies[] = request.getCookies();
        for( int nCk=0; nCk < cookies.length; nCk++ )
            if( cookies[nCk].getName().compareTo(strName) == 0 )
                return unescape( cookies[nCk].getValue().toString() );
        return strDefault;

   public static String unescape(String strIn) 
	/* you get the idea.... */

however, on tomcat 4.0 the unescape is already being performed, so the
string returned is decoded twice (and therefore corrupted).

what is the best way to get the decoded cookie value that will work on both
version of tomcat ?

Thanks in advance,
Stuart James.

Email Disclaimer

This communication is for the attention of the
named recipient only and should not be passed
on to any other person. Information relating to
any company or security, is for information
purposes only and should not be interpreted as
a solicitation or offer to buy or sell any security.
The information on which this communication is based
has been obtained from sources we believe to be reliable,
but we do not guarantee its accuracy or completeness.
All expressions of opinion are subject to change
without notice.  All e-mail messages, and associated attachments,
are subject to interception and monitoring for lawful business purposes.

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message