Encoding servlets with UTF-8 on WildFly

Samir picture Samir · Jul 3, 2015 · Viewed 11.5k times · Source

I used to run my JavaEE applications on GlassFish server, and there was no problem with the encoding type (UTF-8) since I added the following property in JVM Settings of the server:

file.encoding = UTF-8

Now, I'm using WildFly server instead, and I've done the supposed configuration to set the encoding type into UTF-8 but characters are still appearing with wrong encoding not only on the web page but also while debugging the application with Eclipse, the response data loaded using (web servlet requests) are not UTF-8 encoded. Below is what I did on WildFly:

snapshot1

snapshot2

Answer

user158037 picture user158037 · Jul 28, 2016

Wildfly now uses Undertow, so check for that subsystem in you configuration file:

<subsystem xmlns="urn:jboss:domain:undertow:3.0">
      <server name="default-server">
         <http-listener name="default" socket-binding="http" redirect-socket="https" url-charset="UTF-8" />
      </server>
      <servlet-container default-encoding="UTF-8" name="default">
         <jsp-config />
         <websockets />
      </servlet-container>
   </subsystem>

With url-charset and default-encoding set there is no need for filter.