[Solved] How to get tomcat to understand MacRoman (x-mac-roman) charset from my Mac keyboard? [duplicate]


Use UTF-8 instead. It’s understood by every self-respected client side and server side operating system platform. It’s also considered the standard character encoding these days. Tomcat still defaults to the old ISO 8859-1 charset as to decoding GET request parameters and to the server platform default encoding as to decoding POST request parameters.

To set the GET request encoding, edit the desired HTTP connector in Tomcat’s /conf/server.xml:

<Connector ... URIEncoding="UTF-8">

To set the POST request encoding, create a servlet filter which basically does the following in the doFilter() method and map it on the URL-pattern matching all POST requests such as *.jsp or /*:

request.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);

To tell JSP to use the specified encoding on generating the response (you still need to make sure that you save the JSP files using the very same encoding) which will implicitly also tell the client to use UTF-8 to interpret the response and encode the subsequent request, set the following in top of every JSP:

<%@page pageEncoding="UTF-8"%>

Or set the following configuration entry in webapp’s web.xml, so that it get applied on every single JSP:

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <page-encoding>UTF-8</page-encoding>
    </jsp-property-group>
</jsp-config>

If you happen to use a database, don’t forget to set the proper encoding in there as well.

See also:

solved How to get tomcat to understand MacRoman (x-mac-roman) charset from my Mac keyboard? [duplicate]