1

In my maven project I have a html form that post data to a HttpServlet. On the moment I post special characters in the html form (e.g. "jänsen", the HttpServlet receives "Jänsen".

I think I need to change settings to UTF-8 but I don't know where I have to do that...

Lucas
  • 229
  • 1
  • 3
  • 8

1 Answers1

1

You can try to configure org.apache.catalina.filters.SetCharacterEncodingFilter in your web.xml as next:

<filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>ignore</param-name>
        <param-value>false</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Filter that sets the character encoding to be used in parsing the incoming request, either unconditionally or only if the client did not specify a character encoding.

More info about this filter here

Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122