You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mircea LUTIC <mi...@yahoo.com> on 2010/04/21 10:40:19 UTC

UTF-8 encoding in Tomcat 6.0

Hello,


I'm having trouble convincing tomcat 6.0 to take UTF-8 strings.
I created an encoding filter with no luck. 

/**
    Here is the Utf8 Filter that fails for me in 
Tomcat 6.0.20 / Eclipse-Galileo / Windows Vista (6.0.6002) <---> Firefox 3.6.3.
        java version "1.6.0_20"
        Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
        Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)
    Everything is on my  laptop (http://localhost:8060).
    
    What I do is create a GET string (based on parameters from a showModalDialog)
    by script and send it (from Firefox) to the (localhost) server 
    which is running under eclipse with a breakpoint in the EncodingFilter.
    
    Note that the system locale is ro_RO (may have an influence)

 * 
 * set in appl/WebContent/web.xml:
 * 
 <filter>
    <filter-name>EncodingFilter</filter-name>
    <filter-class>ro.lutic.transcode.EncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>

 * 
 * set in tomcat/conf/server.xml at <Connector protocol="HTTP/1.1
 * 
    URIEncoding="UTF-8"   

 */


public class EncodingFilter implements Filter 
{
    private String encoding;
    private FilterConfig filterConfig;
    public EncodingFilter() {}
    public void destroy() {}

    public void init(FilterConfig fc) throws ServletException 
    {
        this.filterConfig = fc;
        this.encoding = filterConfig.getInitParameter("encoding");
    }
    
    public void doFilter
        (ServletRequest  request
        ,ServletResponse response
        , FilterChain chain
        ) throws IOException, ServletException 
    {
        String clientEncoding=request.getCharacterEncoding();
        String Name;

        String fileEncoding=System.getProperty("file.encoding");
        if (fileEncoding==null || !fileEncoding.equals("UTF-8"))// eclipse says it's already UTF-8
            System.setProperty("file.encoding", "UTF-8");    // so this never gets executed
        
        if(null == clientEncoding)    // this is always null
             request.setCharacterEncoding(encoding);// so this is always set
             
        //String uri=request instanceof HttpServletRequest?((HttpServletRequest)request).getRequestURI():null;if (uri!=null)uri+="";
        //window.location=scriptCreatedUrl;
        // using alert(scriptCreatedUrl) I can see that
        // GET sent Name=revoluție as Name=revolu%C8%9Bie (correct) 
        
        Name=request.getParameter("Name");
        if (Name!=null)
        {
            java.util.Locale lang=request.getLocale();//ro_RO
            check(Name, lang);
                
            check("larevoluție"   , lang);// these are ok
            check("_el_piraña"    , lang);
            check("_qi_gong气功"  , lang);
            check("_psyche_ψυχή"  , lang);
            check("_shalom_שָׁלוֹם"  , lang);
            check("_salaam_سَلاَمٌ"   , lang);
            check("_Baikal_Байка́л", lang);
        }

        chain.doFilter(request, response);
    }
    void check(String Name, java.util.Locale lang)
    {
        int c8=Name.codePointAt(8);//c6=200=C8 // should be 539=21Bh = ț
        int c9=Name.codePointAt(9);//c7=155=9B // should be 105= 69h = i
        char ch[]={Name.charAt(8),Name.charAt(9)};
        int x=c8+c9;    //to have eclipse (Galileo) display the above
        String s=new String(ch); 
    }
}
/*
 *     also typed "about:config" in the (Firefox) address bar.
    Used the filter input to search for "network.standard-url.encode-query-utf8" property.
    turned it to true & restarted the browser: no luck
 */


Here is also a page that sends a failing request:

<%@ page language="java"
    pageEncoding="UTF-8" 
    contentType="text/html; charset=UTF-8"
 %>

http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UTF-8</title>
<script>
function send()
{
    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))
}
</script>
</head>
<body>
<button onclick="send()">send</button>
</body>
</html>

Re: UTF-8 encoding in Tomcat 6.0

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

Mircea,

On 4/21/2010 2:46 PM, Mircea LUTIC wrote:
> 	1. If the filter does not influence the decoding of the GET  parameters why is it called on GET requests? 

Because you have mostly likely configured it to be invoked when a GET
request is processed. Tomcat doesn't have any idea what your filter
does: it just calls it whenever appropriate (where the definition of
"appropriate" is based upon your configuration in web.xml).

> 	2. How about http : PUT, HEAD, etc?

It will be called for all HTTP methods unless you configure it to be
called otherwise.

> 	3. I did what this page says: http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8

That's a good start, but it won't solve all your HTTP GET problems
because you simply cannot control what the client does with the
parameter encoding. It's always better to use HTTP POST when sending
non-US-ASCII-encoded text.

> What if I want to build a fully UTF-8 application that will be posted on a web hosting provider where I have no access to server.xml (because this is a common file)?

You'll have to either ask your ISP what URIEncoding they use (and hope
they use UTF-8) or use HTTP POST instead of HTTP GET.

> 	4. I didn't sniff the wire - I only had a look at the  URL I send with the javascript alert function.

Sniffing the wire would be a good thing to do: you'll see what the
encoding looks like on the way from the client to the server.

> 	5. "Utf8encode" converts Unicode strings to strings of bytes in UTF-8 encoding
> (see here: http://www.webtoolkit.info/javascript-utf8.html).
> 	6. "escape" (a standard script function) converts characters not acceptable for http (like slashes) 
> to the %XX  notation. 
> 	7. Combined escape(Utf8encode("larevoluție"))="larevolu%C8%9Bie"

Okay. Have you confirmed that the server is getting the encoded URL the
way you think it should be encoded?

> 	8. POST is not really an acceptable solution because I don't know in advance what the keys of the request will be ("Name" in 
> the example) neither how many they are & POST requires using a html <form>.

Yes, on a web page, POST requires using a <FORM>. What's wrong with
that? I'm not sure I understand what you mean when you say you don't
know in advance what the keys of the request will be.

> (what I do is build an  
> URL in javascript/emacscript from a structured object returned by showModalDialog then alert(scriptBuiltUrl); 
> window.location=scriptBuiltUrl;
> ).

If you are using javascript to send the data to the server, I would
think that switching from GET to POST would be trivial.

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

iEYEARECAAYFAkvPUiAACgkQ9CaO5/Lv0PCzgACeO2s4vDa1XqpBV31qwsHIxdMU
uGgAnRHx64NOG/7RPky13Pq5ErwA+xiW
=Xc4I
-----END PGP SIGNATURE-----

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


Re: UTF-8 encoding in Tomcat 6.0

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

Mircea,

On 4/21/2010 2:46 PM, Mircea LUTIC wrote:
> 	1. If the filter does not influence the decoding of the GET  parameters why is it called on GET requests? 

Because you have mostly likely configured it to be invoked when a GET
request is processed. Tomcat doesn't have any idea what your filter
does: it just calls it whenever appropriate (where the definition of
"appropriate" is based upon your configuration in web.xml).

> 	2. How about http : PUT, HEAD, etc?

It will be called for all HTTP methods unless you configure it to be
called otherwise.

> 	3. I did what this page says: http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8

That's a good start, but it won't solve all your HTTP GET problems
because you simply cannot control what the client does with the
parameter encoding. It's always better to use HTTP POST when sending
non-US-ASCII-encoded text.

> What if I want to build a fully UTF-8 application that will be posted on a web hosting provider where I have no access to server.xml (because this is a common file)?

You'll have to either ask your ISP what URIEncoding they use (and hope
they use UTF-8) or use HTTP POST instead of HTTP GET.

> 	4. I didn't sniff the wire - I only had a look at the  URL I send with the javascript alert function.

Sniffing the wire would be a good thing to do: you'll see what the
encoding looks like on the way from the client to the server.

> 	5. "Utf8encode" converts Unicode strings to strings of bytes in UTF-8 encoding
> (see here: http://www.webtoolkit.info/javascript-utf8.html).
> 	6. "escape" (a standard script function) converts characters not acceptable for http (like slashes) 
> to the %XX  notation. 

Okay. Have you confirmed that the server is getting the encoded URL the
way you think it should be encoded?

> 	7. Combined escape(Utf8encode("larevoluție"))="larevolu%C8%9Bie"
> 	8. POST is not really an acceptable solution because I don't know in advance what the keys of the request will be ("Name" in 
> the example) neither how many they are & POST requires using a html <form>.
> (what I do is build an  
> URL in javascript/emacscript from a structured object returned by showModalDialog then alert(scriptBuiltUrl); 
> window.location=scriptBuiltUrl;
> ). Thank you for your help.
> Mircea
> 
> 
> 
> 
> 
> ________________________________
> From: Christopher Schultz <ch...@christopherschultz.net>
> To: Tomcat Users List <us...@tomcat.apache.org>
> Sent: Wed, 21 April, 2010 18:43:21
> Subject: Re: UTF-8 encoding in Tomcat 6.0
> 
> Mircea,
> 
> On 4/21/2010 6:56 AM, Mircea LUTIC wrote:
>> The filter does get called on my GET request.
> 
> Of course.
> 
>> In my understanding, a filter is the reccomended method of handling
>> UTF-8 for both GET & POST (as well as other methods like HEAD, PUT
>> etc.).
> 
> The filter cannot influence the way that GET parameters are decoded. The
> only way to change that is to set URIEncoding="UTF-8" on your
> <Connector> in server.xml.
> 
> Your best bet is to transfer all non-US-ASCII data in request /bodies/
> by using HTTP POST.
> 
> If HTTP POST is not acceptable, please let us know why and perhaps we
> can suggest some alternatives.
> 
> This looks a bit weird to me:
>>    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))
> 
> What does the Utf8encode function do? What does the escape function do?
> 
> Have you tried snooping the HTTP conversation using a browser plug-in
> and/or a line sniffer like Wireshark? What does the data doing over the
> TCP/IP connection look like?
> 
> -chris

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



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

iEYEARECAAYFAkvPUkMACgkQ9CaO5/Lv0PDhHQCgjgtY7redg8MkBOAdw5krikRH
5DAAoKehO35ziv8nxOBtTQBJojpHComd
=Pl8T
-----END PGP SIGNATURE-----

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


Re: UTF-8 encoding in Tomcat 6.0

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

André,

On 4/21/2010 3:20 PM, André Warnier wrote:
> Mircea LUTIC wrote:
>> Hello Chris,
>>
> I will save Chris one answer :
>>
>>     1. If the filter does not influence the decoding of the GET 
>> parameters why is it called on GET requests? 
> 
> Because the filter may want to, for example, modify or add request
> headers to the request (or response headers). Or it may want to change..
> the parameters, or rather the request's "query string" as a whole (the
> part of the URL after the "?").
> 
> I think what Chris meant, is that the filter does not influence the way
> in which a call like getParameters() works.  The standard
> getParameters() method takes the request URI (as it sees it by the time
> it runs) and parses its query_string part into a table of parameter
> names and values, according to fixed rules which you cannot change.

(Other than setting the URIEncoding attribute on the <Connector>, of
course.)

> What your filter /could/ do, is to create a "request wrapper object"
> containing the original request.  This request wrapper would for example
> pass an already-modifed request URI to the getParameters() method.
> Or it could re-define the getParmeters() method, to return modified
> parameter values.

This may or may not work the way you expect it to work. I would
recommend lots of testing. :)

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

iEYEARECAAYFAkvPUwoACgkQ9CaO5/Lv0PC6rACeMcZv4wblmJPHT0ojLl54Mm0T
MsMAoKYTIIxlaEL8SV5TaVNGdjFk3Sun
=+uD5
-----END PGP SIGNATURE-----

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


Re: UTF-8 encoding in Tomcat 6.0

Posted by André Warnier <aw...@ice-sa.com>.
Mircea LUTIC wrote:
> Hello Chris,
> 
I will save Chris one answer :
> 
> 	1. If the filter does not influence the decoding of the GET  parameters why is it called on GET requests? 

Because the filter may want to, for example, modify or add request 
headers to the request (or response headers). Or it may want to change.. 
the parameters, or rather the request's "query string" as a whole (the 
part of the URL after the "?").

I think what Chris meant, is that the filter does not influence the way 
in which a call like getParameters() works.  The standard 
getParameters() method takes the request URI (as it sees it by the time 
it runs) and parses its query_string part into a table of parameter 
names and values, according to fixed rules which you cannot change.

What your filter /could/ do, is to create a "request wrapper object" 
containing the original request.  This request wrapper would for example 
pass an already-modifed request URI to the getParameters() method.
Or it could re-define the getParmeters() method, to return modified 
parameter values.

When an application then runs and calls getParameters(), it will get the 
result of the getParameters() of your wrapper object, instead of the 
getParameters() of the original object.
For example, the result would be already-"translated" parameter 
names/values.

(You have to do it this way, because the original HttpServletRequest 
object is immutable, it cannot be modified directly.)

> 	2. How about http : PUT, HEAD, etc?

Same thing.
And same thing for the request body, if any.


There are some additional nuances and details to what I wrote above, but 
I hope that this already helps somewhat.

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


Re: UTF-8 encoding in Tomcat 6.0

Posted by Mircea LUTIC <mi...@yahoo.com>.
Hello Chris,


	1. If the filter does not influence the decoding of the GET  parameters why is it called on GET requests? 
	2. How about http : PUT, HEAD, etc?
	3. I did what this page says: http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8
What if I want to build a fully UTF-8 application that will be posted on a web hosting provider where I have no access to server.xml (because this is a common file)?
	4. I didn't sniff the wire - I only had a look at the  URL I send with the javascript alert function.

	5. "Utf8encode" converts Unicode strings to strings of bytes in UTF-8 encoding
(see here: http://www.webtoolkit.info/javascript-utf8.html). 
	6. "escape" (a standard script function) converts characters not acceptable for http (like slashes) 
to the %XX  notation. 
	7. Combined escape(Utf8encode("larevoluție"))="larevolu%C8%9Bie"
	8. POST is not really an acceptable solution because I don't know in advance what the keys of the request will be ("Name" in 
the example) neither how many they are & POST requires using a html <form>.
(what I do is build an  
URL in javascript/emacscript from a structured object returned by showModalDialog then alert(scriptBuiltUrl); 
window.location=scriptBuiltUrl;
). Thank you for your help.
Mircea





________________________________
From: Christopher Schultz <ch...@christopherschultz.net>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Wed, 21 April, 2010 18:43:21
Subject: Re: UTF-8 encoding in Tomcat 6.0

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

Mircea,

On 4/21/2010 6:56 AM, Mircea LUTIC wrote:
> The filter does get called on my GET request.

Of course.

> In my understanding, a filter is the reccomended method of handling
> UTF-8 for both GET & POST (as well as other methods like HEAD, PUT
> etc.).

The filter cannot influence the way that GET parameters are decoded. The
only way to change that is to set URIEncoding="UTF-8" on your
<Connector> in server.xml.

Your best bet is to transfer all non-US-ASCII data in request /bodies/
by using HTTP POST.

If HTTP POST is not acceptable, please let us know why and perhaps we
can suggest some alternatives.

This looks a bit weird to me:
>    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))

What does the Utf8encode function do? What does the escape function do?

Have you tried snooping the HTTP conversation using a browser plug-in
and/or a line sniffer like Wireshark? What does the data doing over the
TCP/IP connection look like?

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

iEYEARECAAYFAkvPHRkACgkQ9CaO5/Lv0PDVkgCgu3dZM9mFNYXDjOBATjvJ5MMP
sN4AniN4aNLVnqsiEL7EzkxzVm4wp83F
=MpSC
-----END PGP SIGNATURE-----

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

Re: UTF-8 encoding in Tomcat 6.0

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

Mircea,

On 4/21/2010 6:56 AM, Mircea LUTIC wrote:
> The filter does get called on my GET request.

Of course.

> In my understanding, a filter is the reccomended method of handling
> UTF-8 for both GET & POST (as well as other methods like HEAD, PUT
> etc.).

The filter cannot influence the way that GET parameters are decoded. The
only way to change that is to set URIEncoding="UTF-8" on your
<Connector> in server.xml.

Your best bet is to transfer all non-US-ASCII data in request /bodies/
by using HTTP POST.

If HTTP POST is not acceptable, please let us know why and perhaps we
can suggest some alternatives.

This looks a bit weird to me:
>    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))

What does the Utf8encode function do? What does the escape function do?

Have you tried snooping the HTTP conversation using a browser plug-in
and/or a line sniffer like Wireshark? What does the data doing over the
TCP/IP connection look like?

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

iEYEARECAAYFAkvPHRkACgkQ9CaO5/Lv0PDVkgCgu3dZM9mFNYXDjOBATjvJ5MMP
sN4AniN4aNLVnqsiEL7EzkxzVm4wp83F
=MpSC
-----END PGP SIGNATURE-----

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


Re: UTF-8 encoding in Tomcat 6.0

Posted by Mircea LUTIC <mi...@yahoo.com>.
Also, my application will eventually be put on a web- based hosting provider and I may not have access to the server.xml file. What I want is my application to be fully UTF-8 based regardless of what the server is configured like.
The request javax.servlet.Filter system which is configured in the web.xml file seems to be the way to do it.

Thank you,
Mircea.





________________________________
From: Ake Tangkannaond <ia...@gmail.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Wed, 21 April, 2010 14:13:18
Subject: RE: UTF-8 encoding in Tomcat 6.0

Where do you see the recommendation of using filter to handle utf8 char encoding in GET ?


-Ake

-----Original Message-----
From: Mircea LUTIC [mailto:mircea_lutic@yahoo.com] 
Sent: Wednesday, April 21, 2010 5:57 PM
To: Tomcat Users List
Subject: Re: UTF-8 encoding in Tomcat 6.0

The filter does get called on my GET request.
In my understanding, a filter is the reccomended method of handling UTF-8 for both GET & POST (as well as other methods like HEAD, PUT etc.).

When the request is "test.jsp?Name=larevolu%C8%9Bie" as in the example page
the EncodingFilter.doFilter function is being called and it calls 
the EncodingFilter.check function as below

        Name=request.getParameter("Name");    
        if (Name!=null)
            check(Name, lang);

and the String Name is incorrect as mentionned in the comment below:


void check(String Name, java.util.Locale lang)
{
    int c8=Name.codePointAt(8);//c8=200=C8 // should be 539=21Bh = ț
    int c9=Name.codePointAt(9);//c9=155=9B // should be 105= 69h = i
    char ch[]={Name.charAt(8),Name.charAt(9)};
    int x=c8+c9;    //to have eclipse (Galileo) display the above
    String s=new String(ch); 
}
    

server.xml contains the following:

    <Connector port="8060" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding="UTF-8"  /> 

This is because my tomcat 6 is set to work on 8060 with no redirect because this is a debug setting.
(some time ago I also had tomcat 5 on 8050 but at that time I didn't check the UTF-8 issue)
Thanks for you help.
Mircea.



________________________________
From: Ake Tangkannaond <ia...@gmail.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Wed, 21 April, 2010 12:42:36
Subject: RE: UTF-8 encoding in Tomcat 6.0

Hi Mircea,



That filter you wrote is for POST and it has nothing to do with GET request.



Have you check the documentation on the conf/server.xml on the following line?

    <Connector port="8080" protocol="HTTP/1.1" 

               connectionTimeout="20000" 

               redirectPort="8443" URIEncoding="UTF-8"/>





-Ake



From: Mircea LUTIC [mailto:mircea_lutic@yahoo.com] 
Sent: Wednesday, April 21, 2010 3:40 PM
To: users@tomcat.apache.org
Subject: UTF-8 encoding in Tomcat 6.0



Hello,


I'm having trouble convincing tomcat 6.0 to take UTF-8 strings.
I created an encoding filter with no luck. 

/**
    Here is the Utf8 Filter that fails for me in 
Tomcat 6.0.20 / Eclipse-Galileo / Windows Vista (6.0.6002) <---> Firefox 3.6.3.
        java version "1.6.0_20"
        Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
        Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)
    Everything is on my  laptop (http://localhost:8060).
    
    What I do is create a GET string (based on parameters from a showModalDialog)
    by script and send it (from Firefox) to the (localhost) server 
    which is running under eclipse with a breakpoint in the EncodingFilter.
    
    Note that the system locale is ro_RO (may have an influence)

* 
* set in appl/WebContent/web.xml:
* 
<filter>
    <filter-name>EncodingFilter</filter-name>
    <filter-class>ro.lutic.transcode.EncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>

* 
* set in tomcat/conf/server.xml at <Connector protocol="HTTP/1.1
* 
    URIEncoding="UTF-8"  

*/


public class EncodingFilter implements Filter 
{
    private String encoding;
    private FilterConfig filterConfig;
    public EncodingFilter() {}
    public void destroy() {}

    public void init(FilterConfig fc) throws ServletException 
    {
        this.filterConfig = fc;
        this.encoding = filterConfig.getInitParameter("encoding");
    }
    
    public void doFilter
        (ServletRequest  request
        ,ServletResponse response
        , FilterChain chain
        ) throws IOException, ServletException 
    {
        String clientEncoding=request.getCharacterEncoding();
        String Name;

        String fileEncoding=System.getProperty("file.encoding");
        if (fileEncoding==null || !fileEncoding.equals("UTF-8"))// eclipse says it's already UTF-8
            System.setProperty("file.encoding", "UTF-8");    // so this never gets executed
        
        if(null == clientEncoding)    // this is always null
             request.setCharacterEncoding(encoding);// so this is always set
            
        //String uri=request instanceof HttpServletRequest?((HttpServletRequest)request).getRequestURI():null;if (uri!=null)uri+="";
        //window.location=scriptCreatedUrl;
        // using alert(scriptCreatedUrl) I can see that
        // GET sent Name=revoluție as Name=revolu%C8%9Bie (correct) 
        
        Name=request.getParameter("Name");
        if (Name!=null)
        {
            java.util.Locale lang=request.getLocale();//ro_RO
            check(Name, lang);
                
            check("larevoluție"   , lang);// these are ok
            check("_el_piraña"    , lang);
            check("_qi_gong气功"  , lang);
            check("_psyche_ψυχή"  , lang);
            check("_shalom_שָׁלוֹם"  , lang);
            check("_salaam_سَلاَمٌ"   , lang);
            check("_Baikal_Байка́л", lang);
        }

        chain.doFilter(request, response);
    }
    void check(String Name, java.util.Locale lang)
    {
        int c8=Name.codePointAt(8);//c6=200=C8 // should be 539=21Bh = ț
        int c9=Name.codePointAt(9);//c7=155=9B // should be 105= 69h = i
        char ch[]={Name.charAt(8),Name.charAt(9)};
        int x=c8+c9;    //to have eclipse (Galileo) display the above
        String s=new String(ch); 
    }
}
/*
*     also typed "about:config" in the (Firefox) address bar.
    Used the filter input to search for "network.standard-url.encode-query-utf8" property.
    turned it to true & restarted the browser: no luck
*/


Here is also a page that sends a failing request:

<%@ page language="java"
    pageEncoding="UTF-8" 
    contentType="text/html; charset=UTF-8"
%>

http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UTF-8</title>
<script>
function send()
{
    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))
}
</script>
</head>
<body>
<button onclick="send()">send</button>
</body>
</html>


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

Re: UTF-8 encoding in Tomcat 6.0

Posted by Mircea LUTIC <mi...@yahoo.com>.
Here:
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8





________________________________
From: Ake Tangkannaond <ia...@gmail.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Wed, 21 April, 2010 14:13:18
Subject: RE: UTF-8 encoding in Tomcat 6.0

Where do you see the recommendation of using filter to handle utf8 char encoding in GET ?


-Ake

-----Original Message-----
From: Mircea LUTIC [mailto:mircea_lutic@yahoo.com] 
Sent: Wednesday, April 21, 2010 5:57 PM
To: Tomcat Users List
Subject: Re: UTF-8 encoding in Tomcat 6.0

The filter does get called on my GET request.
In my understanding, a filter is the reccomended method of handling UTF-8 for both GET & POST (as well as other methods like HEAD, PUT etc.).

When the request is "test.jsp?Name=larevolu%C8%9Bie" as in the example page
the EncodingFilter.doFilter function is being called and it calls 
the EncodingFilter.check function as below

        Name=request.getParameter("Name");    
        if (Name!=null)
            check(Name, lang);

and the String Name is incorrect as mentionned in the comment below:


void check(String Name, java.util.Locale lang)
{
    int c8=Name.codePointAt(8);//c8=200=C8 // should be 539=21Bh = ț
    int c9=Name.codePointAt(9);//c9=155=9B // should be 105= 69h = i
    char ch[]={Name.charAt(8),Name.charAt(9)};
    int x=c8+c9;    //to have eclipse (Galileo) display the above
    String s=new String(ch); 
}
    

server.xml contains the following:

    <Connector port="8060" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding="UTF-8"  /> 

This is because my tomcat 6 is set to work on 8060 with no redirect because this is a debug setting.
(some time ago I also had tomcat 5 on 8050 but at that time I didn't check the UTF-8 issue)
Thanks for you help.
Mircea.



________________________________
From: Ake Tangkannaond <ia...@gmail.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Wed, 21 April, 2010 12:42:36
Subject: RE: UTF-8 encoding in Tomcat 6.0

Hi Mircea,



That filter you wrote is for POST and it has nothing to do with GET request.



Have you check the documentation on the conf/server.xml on the following line?

    <Connector port="8080" protocol="HTTP/1.1" 

               connectionTimeout="20000" 

               redirectPort="8443" URIEncoding="UTF-8"/>





-Ake



From: Mircea LUTIC [mailto:mircea_lutic@yahoo.com] 
Sent: Wednesday, April 21, 2010 3:40 PM
To: users@tomcat.apache.org
Subject: UTF-8 encoding in Tomcat 6.0



Hello,


I'm having trouble convincing tomcat 6.0 to take UTF-8 strings.
I created an encoding filter with no luck. 

/**
    Here is the Utf8 Filter that fails for me in 
Tomcat 6.0.20 / Eclipse-Galileo / Windows Vista (6.0.6002) <---> Firefox 3.6.3.
        java version "1.6.0_20"
        Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
        Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)
    Everything is on my  laptop (http://localhost:8060).
    
    What I do is create a GET string (based on parameters from a showModalDialog)
    by script and send it (from Firefox) to the (localhost) server 
    which is running under eclipse with a breakpoint in the EncodingFilter.
    
    Note that the system locale is ro_RO (may have an influence)

* 
* set in appl/WebContent/web.xml:
* 
<filter>
    <filter-name>EncodingFilter</filter-name>
    <filter-class>ro.lutic.transcode.EncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>

* 
* set in tomcat/conf/server.xml at <Connector protocol="HTTP/1.1
* 
    URIEncoding="UTF-8"  

*/


public class EncodingFilter implements Filter 
{
    private String encoding;
    private FilterConfig filterConfig;
    public EncodingFilter() {}
    public void destroy() {}

    public void init(FilterConfig fc) throws ServletException 
    {
        this.filterConfig = fc;
        this.encoding = filterConfig.getInitParameter("encoding");
    }
    
    public void doFilter
        (ServletRequest  request
        ,ServletResponse response
        , FilterChain chain
        ) throws IOException, ServletException 
    {
        String clientEncoding=request.getCharacterEncoding();
        String Name;

        String fileEncoding=System.getProperty("file.encoding");
        if (fileEncoding==null || !fileEncoding.equals("UTF-8"))// eclipse says it's already UTF-8
            System.setProperty("file.encoding", "UTF-8");    // so this never gets executed
        
        if(null == clientEncoding)    // this is always null
             request.setCharacterEncoding(encoding);// so this is always set
            
        //String uri=request instanceof HttpServletRequest?((HttpServletRequest)request).getRequestURI():null;if (uri!=null)uri+="";
        //window.location=scriptCreatedUrl;
        // using alert(scriptCreatedUrl) I can see that
        // GET sent Name=revoluție as Name=revolu%C8%9Bie (correct) 
        
        Name=request.getParameter("Name");
        if (Name!=null)
        {
            java.util.Locale lang=request.getLocale();//ro_RO
            check(Name, lang);
                
            check("larevoluție"   , lang);// these are ok
            check("_el_piraña"    , lang);
            check("_qi_gong气功"  , lang);
            check("_psyche_ψυχή"  , lang);
            check("_shalom_שָׁלוֹם"  , lang);
            check("_salaam_سَلاَمٌ"   , lang);
            check("_Baikal_Байка́л", lang);
        }

        chain.doFilter(request, response);
    }
    void check(String Name, java.util.Locale lang)
    {
        int c8=Name.codePointAt(8);//c6=200=C8 // should be 539=21Bh = ț
        int c9=Name.codePointAt(9);//c7=155=9B // should be 105= 69h = i
        char ch[]={Name.charAt(8),Name.charAt(9)};
        int x=c8+c9;    //to have eclipse (Galileo) display the above
        String s=new String(ch); 
    }
}
/*
*     also typed "about:config" in the (Firefox) address bar.
    Used the filter input to search for "network.standard-url.encode-query-utf8" property.
    turned it to true & restarted the browser: no luck
*/


Here is also a page that sends a failing request:

<%@ page language="java"
    pageEncoding="UTF-8" 
    contentType="text/html; charset=UTF-8"
%>

http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UTF-8</title>
<script>
function send()
{
    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))
}
</script>
</head>
<body>
<button onclick="send()">send</button>
</body>
</html>


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

RE: UTF-8 encoding in Tomcat 6.0

Posted by Ake Tangkannaond <ia...@gmail.com>.
Where do you see the recommendation of using filter to handle utf8 char encoding in GET ?


-Ake

-----Original Message-----
From: Mircea LUTIC [mailto:mircea_lutic@yahoo.com] 
Sent: Wednesday, April 21, 2010 5:57 PM
To: Tomcat Users List
Subject: Re: UTF-8 encoding in Tomcat 6.0

The filter does get called on my GET request.
In my understanding, a filter is the reccomended method of handling UTF-8 for both GET & POST (as well as other methods like HEAD, PUT etc.).

When the request is "test.jsp?Name=larevolu%C8%9Bie" as in the example page
the EncodingFilter.doFilter function is being called and it calls 
the EncodingFilter.check function as below

        Name=request.getParameter("Name");    
        if (Name!=null)
            check(Name, lang);

and the String Name is incorrect as mentionned in the comment below:


void check(String Name, java.util.Locale lang)
{
    int c8=Name.codePointAt(8);//c8=200=C8 // should be 539=21Bh = ț
    int c9=Name.codePointAt(9);//c9=155=9B // should be 105= 69h = i
    char ch[]={Name.charAt(8),Name.charAt(9)};
    int x=c8+c9;    //to have eclipse (Galileo) display the above
    String s=new String(ch); 
}
    

server.xml contains the following:

    <Connector port="8060" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding="UTF-8"  /> 

This is because my tomcat 6 is set to work on 8060 with no redirect because this is a debug setting.
(some time ago I also had tomcat 5 on 8050 but at that time I didn't check the UTF-8 issue)
Thanks for you help.
Mircea.



________________________________
From: Ake Tangkannaond <ia...@gmail.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Wed, 21 April, 2010 12:42:36
Subject: RE: UTF-8 encoding in Tomcat 6.0

Hi Mircea,



That filter you wrote is for POST and it has nothing to do with GET request.



Have you check the documentation on the conf/server.xml on the following line?

    <Connector port="8080" protocol="HTTP/1.1" 

               connectionTimeout="20000" 

               redirectPort="8443" URIEncoding="UTF-8"/>





-Ake



From: Mircea LUTIC [mailto:mircea_lutic@yahoo.com] 
Sent: Wednesday, April 21, 2010 3:40 PM
To: users@tomcat.apache.org
Subject: UTF-8 encoding in Tomcat 6.0



Hello,


I'm having trouble convincing tomcat 6.0 to take UTF-8 strings.
I created an encoding filter with no luck. 

/**
    Here is the Utf8 Filter that fails for me in 
Tomcat 6.0.20 / Eclipse-Galileo / Windows Vista (6.0.6002) <---> Firefox 3.6.3.
        java version "1.6.0_20"
        Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
        Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)
    Everything is on my  laptop (http://localhost:8060).
    
    What I do is create a GET string (based on parameters from a showModalDialog)
    by script and send it (from Firefox) to the (localhost) server 
    which is running under eclipse with a breakpoint in the EncodingFilter.
    
    Note that the system locale is ro_RO (may have an influence)

* 
* set in appl/WebContent/web.xml:
* 
<filter>
    <filter-name>EncodingFilter</filter-name>
    <filter-class>ro.lutic.transcode.EncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>

* 
* set in tomcat/conf/server.xml at <Connector protocol="HTTP/1.1
* 
    URIEncoding="UTF-8"  

*/


public class EncodingFilter implements Filter 
{
    private String encoding;
    private FilterConfig filterConfig;
    public EncodingFilter() {}
    public void destroy() {}

    public void init(FilterConfig fc) throws ServletException 
    {
        this.filterConfig = fc;
        this.encoding = filterConfig.getInitParameter("encoding");
    }
    
    public void doFilter
        (ServletRequest  request
        ,ServletResponse response
        , FilterChain chain
        ) throws IOException, ServletException 
    {
        String clientEncoding=request.getCharacterEncoding();
        String Name;

        String fileEncoding=System.getProperty("file.encoding");
        if (fileEncoding==null || !fileEncoding.equals("UTF-8"))// eclipse says it's already UTF-8
            System.setProperty("file.encoding", "UTF-8");    // so this never gets executed
        
        if(null == clientEncoding)    // this is always null
             request.setCharacterEncoding(encoding);// so this is always set
            
        //String uri=request instanceof HttpServletRequest?((HttpServletRequest)request).getRequestURI():null;if (uri!=null)uri+="";
        //window.location=scriptCreatedUrl;
        // using alert(scriptCreatedUrl) I can see that
        // GET sent Name=revoluție as Name=revolu%C8%9Bie (correct) 
        
        Name=request.getParameter("Name");
        if (Name!=null)
        {
            java.util.Locale lang=request.getLocale();//ro_RO
            check(Name, lang);
                
            check("larevoluție"   , lang);// these are ok
            check("_el_piraña"    , lang);
            check("_qi_gong气功"  , lang);
            check("_psyche_ψυχή"  , lang);
            check("_shalom_שָׁלוֹם"  , lang);
            check("_salaam_سَلاَمٌ"   , lang);
            check("_Baikal_Байка́л", lang);
        }

        chain.doFilter(request, response);
    }
    void check(String Name, java.util.Locale lang)
    {
        int c8=Name.codePointAt(8);//c6=200=C8 // should be 539=21Bh = ț
        int c9=Name.codePointAt(9);//c7=155=9B // should be 105= 69h = i
        char ch[]={Name.charAt(8),Name.charAt(9)};
        int x=c8+c9;    //to have eclipse (Galileo) display the above
        String s=new String(ch); 
    }
}
/*
*     also typed "about:config" in the (Firefox) address bar.
    Used the filter input to search for "network.standard-url.encode-query-utf8" property.
    turned it to true & restarted the browser: no luck
*/


Here is also a page that sends a failing request:

<%@ page language="java"
    pageEncoding="UTF-8" 
    contentType="text/html; charset=UTF-8"
%>

http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UTF-8</title>
<script>
function send()
{
    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))
}
</script>
</head>
<body>
<button onclick="send()">send</button>
</body>
</html>


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


Re: UTF-8 encoding in Tomcat 6.0

Posted by Mircea LUTIC <mi...@yahoo.com>.
The filter does get called on my GET request.
In my understanding, a filter is the reccomended method of handling UTF-8 for both GET & POST (as well as other methods like HEAD, PUT etc.).

When the request is "test.jsp?Name=larevolu%C8%9Bie" as in the example page
the EncodingFilter.doFilter function is being called and it calls 
the EncodingFilter.check function as below

        Name=request.getParameter("Name");    
        if (Name!=null)
            check(Name, lang);

and the String Name is incorrect as mentionned in the comment below:


void check(String Name, java.util.Locale lang)
{
    int c8=Name.codePointAt(8);//c8=200=C8 // should be 539=21Bh = ț
    int c9=Name.codePointAt(9);//c9=155=9B // should be 105= 69h = i
    char ch[]={Name.charAt(8),Name.charAt(9)};
    int x=c8+c9;    //to have eclipse (Galileo) display the above
    String s=new String(ch); 
}
    

server.xml contains the following:

    <Connector port="8060" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding="UTF-8"  /> 

This is because my tomcat 6 is set to work on 8060 with no redirect because this is a debug setting.
(some time ago I also had tomcat 5 on 8050 but at that time I didn't check the UTF-8 issue)
Thanks for you help.
Mircea.



________________________________
From: Ake Tangkannaond <ia...@gmail.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Wed, 21 April, 2010 12:42:36
Subject: RE: UTF-8 encoding in Tomcat 6.0

Hi Mircea,



That filter you wrote is for POST and it has nothing to do with GET request.



Have you check the documentation on the conf/server.xml on the following line?

    <Connector port="8080" protocol="HTTP/1.1" 

               connectionTimeout="20000" 

               redirectPort="8443" URIEncoding="UTF-8"/>





-Ake



From: Mircea LUTIC [mailto:mircea_lutic@yahoo.com] 
Sent: Wednesday, April 21, 2010 3:40 PM
To: users@tomcat.apache.org
Subject: UTF-8 encoding in Tomcat 6.0



Hello,


I'm having trouble convincing tomcat 6.0 to take UTF-8 strings.
I created an encoding filter with no luck. 

/**
    Here is the Utf8 Filter that fails for me in 
Tomcat 6.0.20 / Eclipse-Galileo / Windows Vista (6.0.6002) <---> Firefox 3.6.3.
        java version "1.6.0_20"
        Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
        Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)
    Everything is on my  laptop (http://localhost:8060).
    
    What I do is create a GET string (based on parameters from a showModalDialog)
    by script and send it (from Firefox) to the (localhost) server 
    which is running under eclipse with a breakpoint in the EncodingFilter.
    
    Note that the system locale is ro_RO (may have an influence)

* 
* set in appl/WebContent/web.xml:
* 
<filter>
    <filter-name>EncodingFilter</filter-name>
    <filter-class>ro.lutic.transcode.EncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>

* 
* set in tomcat/conf/server.xml at <Connector protocol="HTTP/1.1
* 
    URIEncoding="UTF-8"  

*/


public class EncodingFilter implements Filter 
{
    private String encoding;
    private FilterConfig filterConfig;
    public EncodingFilter() {}
    public void destroy() {}

    public void init(FilterConfig fc) throws ServletException 
    {
        this.filterConfig = fc;
        this.encoding = filterConfig.getInitParameter("encoding");
    }
    
    public void doFilter
        (ServletRequest  request
        ,ServletResponse response
        , FilterChain chain
        ) throws IOException, ServletException 
    {
        String clientEncoding=request.getCharacterEncoding();
        String Name;

        String fileEncoding=System.getProperty("file.encoding");
        if (fileEncoding==null || !fileEncoding.equals("UTF-8"))// eclipse says it's already UTF-8
            System.setProperty("file.encoding", "UTF-8");    // so this never gets executed
        
        if(null == clientEncoding)    // this is always null
             request.setCharacterEncoding(encoding);// so this is always set
            
        //String uri=request instanceof HttpServletRequest?((HttpServletRequest)request).getRequestURI():null;if (uri!=null)uri+="";
        //window.location=scriptCreatedUrl;
        // using alert(scriptCreatedUrl) I can see that
        // GET sent Name=revoluție as Name=revolu%C8%9Bie (correct) 
        
        Name=request.getParameter("Name");
        if (Name!=null)
        {
            java.util.Locale lang=request.getLocale();//ro_RO
            check(Name, lang);
                
            check("larevoluție"   , lang);// these are ok
            check("_el_piraña"    , lang);
            check("_qi_gong气功"  , lang);
            check("_psyche_ψυχή"  , lang);
            check("_shalom_שָׁלוֹם"  , lang);
            check("_salaam_سَلاَمٌ"   , lang);
            check("_Baikal_Байка́л", lang);
        }

        chain.doFilter(request, response);
    }
    void check(String Name, java.util.Locale lang)
    {
        int c8=Name.codePointAt(8);//c6=200=C8 // should be 539=21Bh = ț
        int c9=Name.codePointAt(9);//c7=155=9B // should be 105= 69h = i
        char ch[]={Name.charAt(8),Name.charAt(9)};
        int x=c8+c9;    //to have eclipse (Galileo) display the above
        String s=new String(ch); 
    }
}
/*
*     also typed "about:config" in the (Firefox) address bar.
    Used the filter input to search for "network.standard-url.encode-query-utf8" property.
    turned it to true & restarted the browser: no luck
*/


Here is also a page that sends a failing request:

<%@ page language="java"
    pageEncoding="UTF-8" 
    contentType="text/html; charset=UTF-8"
%>

http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UTF-8</title>
<script>
function send()
{
    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))
}
</script>
</head>
<body>
<button onclick="send()">send</button>
</body>
</html>

RE: UTF-8 encoding in Tomcat 6.0

Posted by Ake Tangkannaond <ia...@gmail.com>.
Hi Mircea,

 

That filter you wrote is for POST and it has nothing to do with GET request.

 

Have you check the documentation on the conf/server.xml on the following line?

    <Connector port="8080" protocol="HTTP/1.1" 

               connectionTimeout="20000" 

               redirectPort="8443" URIEncoding="UTF-8"/>

 

 

-Ake

 

From: Mircea LUTIC [mailto:mircea_lutic@yahoo.com] 
Sent: Wednesday, April 21, 2010 3:40 PM
To: users@tomcat.apache.org
Subject: UTF-8 encoding in Tomcat 6.0

 

Hello,


I'm having trouble convincing tomcat 6.0 to take UTF-8 strings.
I created an encoding filter with no luck. 

/**
    Here is the Utf8 Filter that fails for me in 
Tomcat 6.0.20 / Eclipse-Galileo / Windows Vista (6.0.6002) <---> Firefox 3.6.3.
        java version "1.6.0_20"
        Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
        Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)
    Everything is on my  laptop (http://localhost:8060).
    
    What I do is create a GET string (based on parameters from a showModalDialog)
    by script and send it (from Firefox) to the (localhost) server 
    which is running under eclipse with a breakpoint in the EncodingFilter.
    
    Note that the system locale is ro_RO (may have an influence)

 * 
 * set in appl/WebContent/web.xml:
 * 
 <filter>
    <filter-name>EncodingFilter</filter-name>
    <filter-class>ro.lutic.transcode.EncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>

 * 
 * set in tomcat/conf/server.xml at <Connector protocol="HTTP/1.1
 * 
    URIEncoding="UTF-8"   

 */


public class EncodingFilter implements Filter 
{
    private String encoding;
    private FilterConfig filterConfig;
    public EncodingFilter() {}
    public void destroy() {}

    public void init(FilterConfig fc) throws ServletException 
    {
        this.filterConfig = fc;
        this.encoding = filterConfig.getInitParameter("encoding");
    }
    
    public void doFilter
        (ServletRequest  request
        ,ServletResponse response
        , FilterChain chain
        ) throws IOException, ServletException 
    {
        String clientEncoding=request.getCharacterEncoding();
        String Name;

        String fileEncoding=System.getProperty("file.encoding");
        if (fileEncoding==null || !fileEncoding.equals("UTF-8"))// eclipse says it's already UTF-8
            System.setProperty("file.encoding", "UTF-8");    // so this never gets executed
        
        if(null == clientEncoding)    // this is always null
             request.setCharacterEncoding(encoding);// so this is always set
             
        //String uri=request instanceof HttpServletRequest?((HttpServletRequest)request).getRequestURI():null;if (uri!=null)uri+="";
        //window.location=scriptCreatedUrl;
        // using alert(scriptCreatedUrl) I can see that
        // GET sent Name=revoluție as Name=revolu%C8%9Bie (correct) 
        
        Name=request.getParameter("Name");
        if (Name!=null)
        {
            java.util.Locale lang=request.getLocale();//ro_RO
            check(Name, lang);
                
            check("larevoluție"   , lang);// these are ok
            check("_el_piraña"    , lang);
            check("_qi_gong气功"  , lang);
            check("_psyche_ψυχή"  , lang);
            check("_shalom_שָׁלוֹם"  , lang);
            check("_salaam_سَلاَمٌ"   , lang);
            check("_Baikal_Байка́л", lang);
        }

        chain.doFilter(request, response);
    }
    void check(String Name, java.util.Locale lang)
    {
        int c8=Name.codePointAt(8);//c6=200=C8 // should be 539=21Bh = ț
        int c9=Name.codePointAt(9);//c7=155=9B // should be 105= 69h = i
        char ch[]={Name.charAt(8),Name.charAt(9)};
        int x=c8+c9;    //to have eclipse (Galileo) display the above
        String s=new String(ch); 
    }
}
/*
 *     also typed "about:config" in the (Firefox) address bar.
    Used the filter input to search for "network.standard-url.encode-query-utf8" property.
    turned it to true & restarted the browser: no luck
 */


Here is also a page that sends a failing request:

<%@ page language="java"
    pageEncoding="UTF-8" 
    contentType="text/html; charset=UTF-8"
 %>

http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UTF-8</title>
<script>
function send()
{
    window.location="test.jsp?Name=larevolu%C8%9Bie";//"test.jsp?Name="+escape(Utf8encode("larevoluție"))
}
</script>
</head>
<body>
<button onclick="send()">send</button>
</body>
</html>