Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: URIEncoding

Christopher Schultz

2007-07-26

Replies:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Frederic,

Frederic Bastian wrote:
> The point is that I need to use the java.net.URLEncoder.encode() method,
> e.g. java.net.URLEncoder.encode(myParam, "UTF-8").

You ought to be using the response's character encoding, not whatever
Tomcat (or the browser) is using for URIEncoding.

You want to do this:

java.net.URLEncoder.encode(myParam, request.getCharacterEncoding());

Or, you could do what everybody else in the world does and use a tag
library or some other tool to emit URLs including parameters, etc.

- -chris

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

iD8DBQFGqPMB9CaO5/Lv0PARAiyhAJ4zYvszzqRzArWTfHxMIIWN3sU5aQCfRlBs
g5X8A0Fh88S5Mrmii+Ylg8g=
=y7Mj
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.