Discussion:
URIEncoding
Frederic Bastian
2007-07-26 12:40:37 UTC
Permalink
Hi folks :)


I need my URI to be in UTF-8. In server.xml, I added to the Connector
the attribut : URIEncoding="UTF-8"
This works well. But my question is :

Is there a way to define the URIEncoding in the application itself ?

For instance, you can modify the session timeout in the application
itself (HttpSession.setMaxInactiveInterval()). I would like to modify
the URIEncoding by the same way.

Would anyone know how to achieve that ?
Thanks.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Pulkit Singhal
2007-07-26 13:13:36 UTC
Permalink
Hi Frederic,

I don't know about HttpSession.<method> for settign the URIEncoding.
But you could always do somethign along the lines of:
String uri_utf8 = new String (uri.getBytes("iso-8859-1"), "UTF-8");
inside the application.
Post by Frederic Bastian
Hi folks :)
I need my URI to be in UTF-8. In server.xml, I added to the Connector
the attribut : URIEncoding="UTF-8"
Is there a way to define the URIEncoding in the application itself ?
For instance, you can modify the session timeout in the application
itself (HttpSession.setMaxInactiveInterval()). I would like to modify
the URIEncoding by the same way.
Would anyone know how to achieve that ?
Thanks.
---------------------------------------------------------------------
Frederic Bastian
2007-07-26 13:25:37 UTC
Permalink
Hi Pulkit, thanks for your answer.

The matter is that Tomcat won't get the correct values of the parameters
in the URL. For instance :

If my URI looks like : http://host/?query=%C3%A9%C3%A8
The URI encoding is UTF-8

By default, Tomcat will read this url in ISO-8859-1. So
HttpServletRequest.getParameter("query") will return an incorrect value.
The solution you proposed won't help Tomcat to return a correct value
with the "getParameter" method.

If I add into server.xml the attribut URIEncoding="UTF-8" to the
Connector, Tomcat will correctly read the "query" parameter.
I would like Tomcat to read correctly URL in UTF-8, but without
modifying server.xml.

Any suggestion ?
Post by Pulkit Singhal
Hi Frederic,
I don't know about HttpSession.<method> for settign the URIEncoding.
String uri_utf8 = new String (uri.getBytes("iso-8859-1"), "UTF-8");
inside the application.
Post by Frederic Bastian
Hi folks :)
I need my URI to be in UTF-8. In server.xml, I added to the Connector
the attribut : URIEncoding="UTF-8"
Is there a way to define the URIEncoding in the application itself ?
For instance, you can modify the session timeout in the application
itself (HttpSession.setMaxInactiveInterval()). I would like to modify
the URIEncoding by the same way.
Would anyone know how to achieve that ?
Thanks.
---------------------------------------------------------------------
--
Frederic Bastian, PhD student
Department of Ecology and Evolution
Biophore, University of Lausanne, 1015 Lausanne, Switzerland.
tel: +41 21 692 4221
http://www.unil.ch/dee/page22707.html

Swiss Institute of Bioinformatics
http://www.isb-sib.ch/


---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Pulkit Singhal
2007-07-26 15:06:41 UTC
Permalink
How about:
====
String queryString = HttpServletRequest.getParameter("query");
queryString = new String(queryString.getBytes("iso-8859-1"), "UTF-8");
====

Its not very graceful so you can even make a 1-line-method for doing this
and have:
====
decodeURIParams(a, b, c) {
return new String((HttpServletRequest.getParameter(a)).getBytes(b), c);
}

String queryString = decodeURIParams("query", URI_ENCODING_CONST,
URI_DECODING_CONST));
====

This is all pseudo-code but I hope you see what I mean.
Post by Frederic Bastian
Hi Pulkit, thanks for your answer.
The matter is that Tomcat won't get the correct values of the parameters
If my URI looks like : http://host/?query=%C3%A9%C3%A8
The URI encoding is UTF-8
By default, Tomcat will read this url in ISO-8859-1. So
HttpServletRequest.getParameter("query") will return an incorrect value.
The solution you proposed won't help Tomcat to return a correct value
with the "getParameter" method.
If I add into server.xml the attribut URIEncoding="UTF-8" to the
Connector, Tomcat will correctly read the "query" parameter.
I would like Tomcat to read correctly URL in UTF-8, but without
modifying server.xml.
Any suggestion ?
Post by Pulkit Singhal
Hi Frederic,
I don't know about HttpSession.<method> for settign the URIEncoding.
String uri_utf8 = new String (uri.getBytes("iso-8859-1"), "UTF-8");
inside the application.
Post by Frederic Bastian
Hi folks :)
I need my URI to be in UTF-8. In server.xml, I added to the Connector
the attribut : URIEncoding="UTF-8"
Is there a way to define the URIEncoding in the application itself ?
For instance, you can modify the session timeout in the application
itself (HttpSession.setMaxInactiveInterval()). I would like to modify
the URIEncoding by the same way.
Would anyone know how to achieve that ?
Thanks.
---------------------------------------------------------------------
--
Frederic Bastian, PhD student
Department of Ecology and Evolution
Biophore, University of Lausanne, 1015 Lausanne, Switzerland.
tel: +41 21 692 4221
http://www.unil.ch/dee/page22707.html
Swiss Institute of Bioinformatics
http://www.isb-sib.ch/
---------------------------------------------------------------------
Frederic Bastian
2007-07-26 15:38:55 UTC
Permalink
Thx a lot Pulkit, it works just fine.

But my aim is to make portability easier ; What happens if the
URIEncoding of the Connector is not "UTF-8" or "ISO-8859-1", but a
different char encoding ?
Your pseudo-code won't work anymore :(

Is there a way to get the value of the param URIEncoding of the
Connector, so your code will work, whatever the char encoding of the
Connector is ?
Post by Pulkit Singhal
====
String queryString = HttpServletRequest.getParameter("query");
queryString = new String(queryString.getBytes("iso-8859-1"), "UTF-8");
====
Its not very graceful so you can even make a 1-line-method for doing this
====
decodeURIParams(a, b, c) {
return new String((HttpServletRequest.getParameter(a)).getBytes(b), c);
}
String queryString = decodeURIParams("query", URI_ENCODING_CONST,
URI_DECODING_CONST));
====
This is all pseudo-code but I hope you see what I mean.
Post by Frederic Bastian
Hi Pulkit, thanks for your answer.
The matter is that Tomcat won't get the correct values of the parameters
If my URI looks like : http://host/?query=%C3%A9%C3%A8
The URI encoding is UTF-8
By default, Tomcat will read this url in ISO-8859-1. So
HttpServletRequest.getParameter("query") will return an incorrect value.
The solution you proposed won't help Tomcat to return a correct value
with the "getParameter" method.
If I add into server.xml the attribut URIEncoding="UTF-8" to the
Connector, Tomcat will correctly read the "query" parameter.
I would like Tomcat to read correctly URL in UTF-8, but without
modifying server.xml.
Any suggestion ?
Post by Pulkit Singhal
Hi Frederic,
I don't know about HttpSession.<method> for settign the URIEncoding.
String uri_utf8 = new String (uri.getBytes("iso-8859-1"), "UTF-8");
inside the application.
Post by Frederic Bastian
Hi folks :)
I need my URI to be in UTF-8. In server.xml, I added to the Connector
the attribut : URIEncoding="UTF-8"
Is there a way to define the URIEncoding in the application itself ?
For instance, you can modify the session timeout in the application
itself (HttpSession.setMaxInactiveInterval()). I would like to modify
the URIEncoding by the same way.
Would anyone know how to achieve that ?
Thanks.
---------------------------------------------------------------------
--
Frederic Bastian, PhD student
Department of Ecology and Evolution
Biophore, University of Lausanne, 1015 Lausanne, Switzerland.
tel: +41 21 692 4221
http://www.unil.ch/dee/page22707.html
Swiss Institute of Bioinformatics
http://www.isb-sib.ch/
---------------------------------------------------------------------
--
Frederic Bastian, PhD student
Department of Ecology and Evolution
Biophore, University of Lausanne, 1015 Lausanne, Switzerland.
tel: +41 21 692 4221
http://www.unil.ch/dee/page22707.html

Swiss Institute of Bioinformatics
http://www.isb-sib.ch/


---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Caldarale, Charles R
2007-07-26 16:21:27 UTC
Permalink
Subject: Re: URIEncoding
Is there a way to get the value of the param URIEncoding of the
Connector, so your code will work, whatever the char encoding of the
Connector is ?
I'm confused. If the <Connector> already has the proper URIEncoding
value, why do you think the application needs to reprocess the URI with
the same encoding?

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Frederic Bastian
2007-07-26 17:45:42 UTC
Permalink
Post by Caldarale, Charles R
Subject: Re: URIEncoding
Is there a way to get the value of the param URIEncoding of the
Connector, so your code will work, whatever the char encoding of the
Connector is ?
I'm confused. If the <Connector> already has the proper URIEncoding
value, why do you think the application needs to reprocess the URI with
the same encoding?
The point is that I need to use the java.net.URLEncoder.encode() method,
e.g. java.net.URLEncoder.encode(myParam, "UTF-8").

Using a different character encoding than the Connector URIEncoding
leads to problems ; for instance, if the Connector URIEncoding is set to
"ISO-8859-1" (default value), and the URLEncoder.encode() method set to
"UTF-8" => problems (one obvious solution is to modify the URIEncoding)

I would like to use URLEncoder.encode() method with the character
encoding UTF-8 (W3C recommendations). So, I MUST modify the Connector
URIEncoding parameter, but I don't want to, to improve portability.

So I would like to manage this problem in the application itself rather
than in server.xml, for portability purposes. The only solution I see is
to find a way to get the value of the URIEncoding parameters.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Caldarale, Charles R
2007-07-26 18:48:38 UTC
Permalink
Subject: Re: URIEncoding
The point is that I need to use the
java.net.URLEncoder.encode() method,
e.g. java.net.URLEncoder.encode(myParam, "UTF-8").
O.k., so now it appears you need to know the encoding in order to do it
properly on the output side, whereas all the examples being tossed
around earlier in this thread were concerned with the request URI, not a
generated one. That explains quite a bit.
I would like to use URLEncoder.encode() method with the character
encoding UTF-8 (W3C recommendations). So, I MUST modify the Connector
URIEncoding parameter, but I don't want to, to improve portability.
It's available via the MBeans created for each <Connector>, so you could
get at it with JMX.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Christopher Schultz
2007-07-26 19:16:17 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Frederic,
Post by Frederic Bastian
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: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Frederic Bastian
2007-07-26 19:49:33 UTC
Permalink
Post by Christopher Schultz
java.net.URLEncoder.encode(myParam, request.getCharacterEncoding());
This does not work :) request.getCharacterEncoding() is different from
<Connector> URIEncoding. The request character encoding determines in
wich character encodig the parameters value will be return to you. But
it doesn't determine in wich character encoding the URI has to be read.
Post by Christopher Schultz
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.
What's the problem with URLEncoder ? I don't get you :)
Post by Christopher Schultz
Aah, I get it. I don't believe this is possible. I'd love to hear from a
Tomcat developer, though, just to be safe
that would be fine :)

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Christopher Schultz
2007-07-26 20:22:14 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Frederic,
Post by Frederic Bastian
Post by Frederic Bastian
java.net.URLEncoder.encode(myParam,
request.getCharacterEncoding());
This does not work :) request.getCharacterEncoding() is different
from <Connector> URIEncoding. The request character encoding
determines in which character encoding the parameters value will be
return to you.
My mistake. I meant response.getCharacterEncoding().
Post by Frederic Bastian
But it doesn't determine in wich character encoding the URI has to be
read.
But you aren't reading a URI. You're writing one. I'm assuming that you
want to encode a URI for output into a web page. The web page ought to
be written using the response's encoding, not the URIEncoding.
Post by Frederic Bastian
What's the problem with URLEncoder ? I don't get you :)
Nothing. All the things I mentioned used them at the heart (or should).
They just take out the guesswork of which encoding you should be using,
and when to apply it.

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

iD8DBQFGqQJ29CaO5/Lv0PARAuhvAJ9vmHBfszi95wQyVlV2o36yZ4N8SQCfTqKN
puaAISUt3/OrGna00/8dvk4=
=B73f
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Frederic Bastian
2007-07-26 20:46:01 UTC
Permalink
Post by Christopher Schultz
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Frederic,
Post by Frederic Bastian
Post by Frederic Bastian
java.net.URLEncoder.encode(myParam,
request.getCharacterEncoding());
This does not work :) request.getCharacterEncoding() is different
from <Connector> URIEncoding. The request character encoding
determines in which character encoding the parameters value will be
return to you.
My mistake. I meant response.getCharacterEncoding().
Post by Frederic Bastian
But it doesn't determine in wich character encoding the URI has to be
read.
But you aren't reading a URI. You're writing one. I'm assuming that you
want to encode a URI for output into a web page. The web page ought to
be written using the response's encoding, not the URIEncoding.
I'm sorry but I think you don't get it :) Reading and writing URI is
totally different from writing the response output. For instance, you
can set the response character encoding to UTF-8 in order to display
your html in UTF-8, and set the Connector URIEncoding to ISO-8859-1 to
read URI in ISO-8859-1 (and so, you have to encode your URI in ISO-8859-1).

For instance, If you want to make a redirection, you just send a
redirection header, there is no response output writing, so no matter
wich character encoding your web pages are displayed in.

The point is that the character encoding of the <Connector> URIEncoding,
and the character encoding of the URLEncoder method, have to be consistent.
Make the try : set the response character encoding to UTF-8, set the
URLEncoder character encoding to UTF-8, generate a web page including
links with encoded parameters with special chars, and follow these
links. You will see that the server does not interpret correctly the
parameters, because the <Connector> URIEncoding is still set to ISO-8859-1.

So, for portability purpose, I'd like to make the character encoding of
the <Connector> and of the URLEncoder consistent, without modifying the
server.xml file. But it looks pretty impossible :p
Post by Christopher Schultz
Post by Frederic Bastian
What's the problem with URLEncoder ? I don't get you :)
Nothing. All the things I mentioned used them at the heart (or should).
They just take out the guesswork of which encoding you should be using,
and when to apply it.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGqQJ29CaO5/Lv0PARAuhvAJ9vmHBfszi95wQyVlV2o36yZ4N8SQCfTqKN
puaAISUt3/OrGna00/8dvk4=
=B73f
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Christopher Schultz
2007-07-26 21:04:40 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Frederic,
Post by Frederic Bastian
I'm sorry but I think you don't get it :) Reading and writing URI is
totally different from writing the response output.
I'd agree that reading a URI is different, but not writing one. Where
are you writing your URI? Into the response, I'm guessing. In fact, I'm
guessing you're writing it into the response /body/, which ought to be
encoded using the response's declared Content-Type (in the HTTP header).
The encoding used for reading the URI from the request is irrelevant, here.
Post by Frederic Bastian
For instance, you
can set the response character encoding to UTF-8 in order to display
your html in UTF-8, and set the Connector URIEncoding to ISO-8859-1 to
read URI in ISO-8859-1 (and so, you have to encode your URI in ISO-8859-1).
Yes, except that most browsers will use the encoding of the previous
response to encode the URI (unless you have "use UTF-8 URLs" turned on
in the options -- most browsers have this feature, and I think it's
turned on by default these days).
Post by Frederic Bastian
For instance, If you want to make a redirection, you just send a
redirection header, there is no response output writing, so no matter
wich character encoding your web pages are displayed in.
Now we're getting somewhere. You didn't mention that you were talking
about a redirection URI, which will go into a header. The interesting
part now is that HTTP headers do not have a declared character encoding.
Most browsers use UTF-8 for URI encoding, but the headers use ASCII from
what I can tell from the spec.

So... how do you decide which character encoding to use for the URI? You
have to guess. It's stupid, but true. The browser will not tell you the
encoding it uses. Forcing your Connector to use ISO-8859-1 or UTF-8 is
just a guess, too. Using your own code to override the default for the
Connector is just adding confusion to a process already fraught with
problems.

What makes you think that the Connector has the right answer in the
first place?
Post by Frederic Bastian
The point is that the character encoding of the <Connector> URIEncoding,
and the character encoding of the URLEncoder method, have to be consistent.
I believe this to be true only under the following conditions:

1. You are writing a URI to be used in an HTTP header.
2. The URIEncoding used by your Connector was correct in the first
place.

The only way to tell if the encoding was right in the first place is to
encode parameters whose values you /know/ and then check them on the
other end to see if the browser really was using UTF-8 or ISO-8859-1 (or
whatever).
Post by Frederic Bastian
Make the try : set the response character encoding to UTF-8, set the
URLEncoder character encoding to UTF-8, generate a web page including
links with encoded parameters with special chars, and follow these
links. You will see that the server does not interpret correctly the
parameters, because the <Connector> URIEncoding is still set to ISO-8859-1.
If you are setting the URIEncoding of the Connector to UTF-8 and it's
not interpreting it as UTF-8, then Tomcat has a bug. Since you are the
only one experiencing this phenomenon, I'm guessing it's not a bug.

If you have everything set to UTF-8 (as I do in my production apps), you
should not have this problem.
Post by Frederic Bastian
So, for portability purpose, I'd like to make the character encoding of
the <Connector> and of the URLEncoder consistent, without modifying the
server.xml file. But it looks pretty impossible :p
I disagree that the Connector knows any better than you do about how to
encode outgoing URLs. The browser is going to do whatever the heck it
wants, and it's not going to tell you what it did. You just have to guess.

- -chris

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

iD8DBQFGqQxo9CaO5/Lv0PARArLrAJsEtuEyh/60diLe+ttSlW4OO/tfIgCeLQwu
SvSvLxWBuucFh92vlMAUmu8=
=kvt9
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Frederic Bastian
2007-07-26 21:51:35 UTC
Permalink
Post by Christopher Schultz
I'd agree that reading a URI is different, but not writing one. Where
are you writing your URI? Into the response, I'm guessing. In fact, I'm
guessing you're writing it into the response /body/, which ought to be
encoded using the response's declared Content-Type (in the HTTP header).
The encoding used for reading the URI from the request is irrelevant, here.
I disagree. Imagine that you want to write into the response /body/ a
link to a google search, where the search parameter is the special char
"&". Example : http://www.google.com/search?&q=%26
(so the correct way to write it in your response /body/ is: <a
href="http://www.google.com/search?q=%26">your search</a>)

If you just write the link without url encoding or html entities
encoding, the link will be wrong : <a
href="http://www.google.com/search?q=&">your search</a>

If you write the link with html entities encoding, the link will be
wrong : <a href="http://www.google.com/search?q=&amp;">your search</a>

So you have to URLEncode your parameter, to write it into the response
/body/: <a href="http://www.google.com/search?q=%26">your search</a>

So, to generate and write into the response body links that include user
inputs into the parameters, you have to URLEncode the parameters, it is
an absolute necessity !
And that's the point: you can URLEncode them into different character
encodings. And if they are links to your own tomcat server, you need to
URLEncode the parameters in the same character encoding than the
<Connector> URIEncoding.
Post by Christopher Schultz
What makes you think that the Connector has the right answer in the
first place?
Because it is the Connector that will read your URI ;) And so, when
URLEncoding links to your server, the character encoding has to be the same.
Post by Christopher Schultz
Post by Frederic Bastian
You will see that the server does not interpret correctly the
parameters, because the <Connector> URIEncoding is still set to ISO-8859-1.
If you are setting the URIEncoding of the Connector to UTF-8 and it's
not interpreting it as UTF-8, then Tomcat has a bug
I wrote : "<Connector> URIEncoding is still set to ISO-8859-1" ;)
ISO-8859-1 is the default value of the Connector URIEncoding.


Anyway, if we disagree, let's just get back to the point : how to know
the Connector URIEncoding value, inside your application ? :)

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Caldarale, Charles R
2007-07-26 21:57:03 UTC
Permalink
Subject: Re: URIEncoding
how to know the Connector URIEncoding value, inside
your application ? :)
Once again, it's available via the MBean that Tomcat creates for each
<Connector> element.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Frederic Bastian
2007-07-26 22:12:58 UTC
Permalink
Post by Caldarale, Charles R
Once again, it's available via the MBean that Tomcat creates for each
<Connector> element.
I'm sorry i should have missed your reply.

Could you tell me a bit more about how MBean can solve my problem ? I
never used it.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Caldarale, Charles R
2007-07-26 22:31:48 UTC
Permalink
Subject: Re: URIEncoding
Could you tell me a bit more about how MBean can solve my problem ? I
never used it.
Tomcat creates MBeans for most of its internal objects, including
connectors:
http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html

(The same is true for 5.5 if that's what you're using.) The get/set
methods of the MBean allow you to inspect and modify the underlying
objects. Start Tomcat with -Dcom.sun.management.jmxremote and use
JConsole to poke around inside it. Look at the MBeans tab, then down
the Catalina -> Connector -> [port#] -> Attributes branch; you should
see URIEncoding as the first entry.

Study the javax.mananagement.* APIs for details on how to access MBeans.
You may want to look at this tutorial as well:
http://java.sun.com/j2se/1.5.0/docs/guide/management/overview.html

For examples of code that interrogates various MBeans within Tomcat,
wander through the Lambda Probe source:
http://lambdaprobe.org/d/index.htm

Using any of this makes your application Tomcat-specific, of course.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Frederic Bastian
2007-07-26 23:08:24 UTC
Permalink
Thanks for your help, that answers my question pretty well :)
Post by Caldarale, Charles R
Subject: Re: URIEncoding
Could you tell me a bit more about how MBean can solve my problem ? I
never used it.
Tomcat creates MBeans for most of its internal objects, including
http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html
(The same is true for 5.5 if that's what you're using.) The get/set
methods of the MBean allow you to inspect and modify the underlying
objects. Start Tomcat with -Dcom.sun.management.jmxremote and use
JConsole to poke around inside it. Look at the MBeans tab, then down
the Catalina -> Connector -> [port#] -> Attributes branch; you should
see URIEncoding as the first entry.
Study the javax.mananagement.* APIs for details on how to access MBeans.
http://java.sun.com/j2se/1.5.0/docs/guide/management/overview.html
For examples of code that interrogates various MBeans within Tomcat,
http://lambdaprobe.org/d/index.htm
Using any of this makes your application Tomcat-specific, of course.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Christopher Schultz
2007-07-26 19:12:15 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,
Post by Caldarale, Charles R
Subject: Re: URIEncoding
Is there a way to get the value of the param URIEncoding of the
Connector, so your code will work, whatever the char encoding of the
Connector is ?
I'm confused. If the <Connector> already has the proper URIEncoding
value, why do you think the application needs to reprocess the URI with
the same encoding?
He's trying to beat the Connector into using an application-defined
URIEncoding without having to modify server.xml to set up the connector
properly.

Frederic, why are you trying to do this? Are you deploying an
application on a Tomcat over which you have no control?

- -chris

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

iD8DBQFGqPIP9CaO5/Lv0PARAvVyAKCP+bx1oD64GCFI220GSpP7SeN2xgCgp/cd
lg85Bvd8Sf+vlk2Rx/JYHNM=
=dWBq
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Christopher Schultz
2007-07-26 19:06:36 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Frederic,
Post by Frederic Bastian
The matter is that Tomcat won't get the correct values of the parameters
If my URI looks like : http://host/?query=%C3%A9%C3%A8
The URI encoding is UTF-8
By default, Tomcat will read this url in ISO-8859-1.
Yes, but you said that you changed the <Connector> to use UTF-8. Is it
not working? Or, are you looking for an alternative so that you don't
/have to/ set the <Connector>'s URIEncoding?
Post by Frederic Bastian
If I add into server.xml the attribut URIEncoding="UTF-8" to the
Connector, Tomcat will correctly read the "query" parameter.
I would like Tomcat to read correctly URL in UTF-8, but without
modifying server.xml.
Aah, I get it. I don't believe this is possible. I'd love to hear from a
Tomcat developer, though, just to be safe.

- -chris

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

iD8DBQFGqPC89CaO5/Lv0PARAsppAKCk/bkUphulQmhqOt9rsvvM6kWwKgCgjQkM
CtW/PpMkqPJfrMF9I6Jz/fQ=
=tfXB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Loading...