You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Joachim Seibert <js...@seibert-media.net> on 2011/01/26 23:25:51 UTC

java.net.URLEncoder.encode quotes wrong under (my) Tomcat environment

Hi there,

actually I have the problem, that the static encode method from java.net.URLEncoder encodes under the command line different as the tomcat environment on my machine (my workmate with exactly the same setup - see below - doesn't have this problem).

The char "@" is not quoted to "%40" while running under tomcat (servlet).

Any idea which java System environment variable could affect this behavior? And which role tomcat plays with this error?

Example.
Under the command line:
System.out.println(URLEncoder.encode("an@", "UTF-8")); => an%40

Under Tomcat (in a servlet):
System.out.println(URLEncoder.encode("an@", "UTF-8")); => an@

My system:
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)

Tomcat version: 6.0.20

Mac Os X 10.6.6

Thanks a lot for your help.
Yours 
Jo Seibert
www.twitter.com/jseibert



Re: java.net.URLEncoder.encode quotes wrong under (my) Tomcat environment

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jo,

On 1/26/2011 5:25 PM, Joachim Seibert wrote:
> actually I have the problem, that the static encode method from
> java.net.URLEncoder encodes under the command line different as the
> tomcat environment on my machine (my workmate with exactly the same
> setup - see below - doesn't have this problem).

Sounds like a problem with your Java kit: Tomcat has nothing to do with
java.net.URLEncoder.

Are you /absolutely sure/ you are running the same code?

> The char "@" is not quoted to "%40" while running under tomcat (servlet).
> 
> Any idea which java System environment variable could affect this
> behavior? And which role tomcat plays with this error?

I don't believe there are any environment variables that affect the
operation of URLEncoder.encode. Tomcat does not intercept anything like
this.

> Example.
> Under the command line:
> System.out.println(URLEncoder.encode("an@", "UTF-8")); => an%40
> 
> Under Tomcat (in a servlet):
> System.out.println(URLEncoder.encode("an@", "UTF-8")); => an@

What do your "import" statements look like?

> My system:
> java version "1.6.0_22"
> Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
> Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)
> 
> Tomcat version: 6.0.20

No matter what else: upgrade. Your version of Tomcat is quite old.

> Mac Os X 10.6.6

...and your workmate's setup?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1AsNQACgkQ9CaO5/Lv0PBACgCfVoM4jMu7dQgra4P2bD+f4WDc
BB8AoIuFAa4FOABVBPxQeKv1Z3TO0A8n
=YukP
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org