/2016-10-17 19:59 GMT+03:00 R <bittransfer2...@gmail.com>:
> Hi,
> I have a default installation of Tomcat 8.5.6. When I make a POST request
> with a tilde character, and the encoding is set to UTF-8, it seems that my
> servlet handler is decoding it incorrectly. I have to set the character
> encoding on the HttpServletRequest parameter to decode properly, example:
>   protected void doPost(HttpServletRequest request, ...) {
>       // I have to set this manually.
>       request.setCharacterEncoding("UTF-8");
>       // Decoding works now.
>       String test = request.getParam("test");
>       ...
>   }
> Reading the Tomcat docs, it seems like everything should be UTF-8 by
> default. Is there a setting we still have to apply to get UTF-8 to be the
> default encoding?

For GET requests it defaults to UTF-8  (though actually it depends on
STRICT_SERVLET_COMPLIANCE setting. I prefer to explicitly configure
URIEncoding="UTF-8" on a Connector).

For POST requests you need to use
"org.apache.catalina.filters.SetCharacterEncodingFilter" filter (or a
similar 3-rd party filter e.g. the one provided by Spring Framework)
that essentially calls request.setCharacterEncoding() for you.

See webapps/examples/WEB-INF/web.xml for an example.

Best regards,
Konstantin Kolinko

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

Reply via email to