-
1. Re: How to set UTF-8 on JBOSS EAP 6.4
jaysensharma Nov 1, 2015 2:38 PM (in response to j.swiderski)Hello James,
Did you try the following in your "web.xml"
<jsp-config> <jsp-property-group> <url-pattern>/*</url-pattern> <page-encoding>UTF-8</page-encoding> </jsp-property-group> </jsp-config>
Alternate option may be to use a ServletFilter with the following kind of doFilter method which will be applicable for all the requests/responses.
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { response.setContentType("text/html; charset=UTF-8"); request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); chain.doFilter(request, response); }
How are you testing it ? Are you using a JSF based application ?
-
2. Re: How to set UTF-8 on JBOSS EAP 6.4
j.swiderski Nov 10, 2015 11:47 AM (in response to jaysensharma)Hi,
Thanks for your quick reply and sorry for my late one.
First of all let me clarify that I've meant URI_ENCODING for request parameters.
I have tested JBOSS EAP in various settings and here are my results.
It seems that I'm getting the best results with character encoding filter and system property in standalone.xml:
<system-properties>
</system-properties>
<property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
<property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>While this works, it's not what I have expected. I was searching for a global (for every application) way to set UTF-8 for URI_ENCODING in the same way as it is possible in e.g. Tomcat or GlassFish.
In those servers the filter is not really required. Sure you need take care having UTF-8 set everywhere but to set URI_ENCODNING you need to:set below in Tomcat server.xml (Tomcat 6 & 7)
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
set below in GlassFish glassfish-web.xml:
<parameter-encoding default-charset="UTF-8" />Is there a similar global setting for JBOSS EAP?
NOTE: While JBOSS AS 7 requires entry in standalone.xml (described in first post), WildFly 8-9 seem to support UTF-8 by default and JBOSS EAP doesn't seem to have such support.
I can't really understand why all those versions differ so much in that area.Regards,
James
-
3. Re: How to set UTF-8 on JBOSS EAP 6.4
mmusaji Nov 13, 2015 11:13 AM (in response to j.swiderski)Hi
You can add this to your standalone-*.xml file
<system-properties>
<property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
<property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
</system-properties>Regards
Mustafa
-
4. Re: How to set UTF-8 on JBOSS EAP 6.4
mmusaji Nov 13, 2015 11:14 AM (in response to j.swiderski)Apologies, I just re-read that's what you initially tried and it didn't work! This should work in EAP. Can you tell us what you're seeing happening?
-
5. Re: How to set UTF-8 on JBOSS EAP 6.4
j.swiderski Nov 15, 2015 6:24 PM (in response to mmusaji)Thanks for your reply. I have dug into this issue further and here are my final findings:
Ok, So I have started to look for places where encoding could be set. I have found out that sun.jnu.encoding and file.encoding are in fact set to cp-1250 instead of UTF-8.
I had doubts if this can influence Query string but decided to give it a try. I have set UTF-8 filter in my app, character encoding to UTF-8 and below in standalone.xml
<system-properties>
<property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
<property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="file.encoding" value="UTF-8"/>
</system-properties>
Unfortunatelly that didn't work.
Then I have remembered that in my old JBoss AS 7, I haven't been using USE_BODY_ENCODING_FOR_QUERY_STRING.
I have decided to change standalone configuration to
<system-properties>
<property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
</system-properties>
and this time it has worked!!!
Mustafa Musaji you were right, there is a global setting for JBoss EAP. The problem was that USE_BODY_ENCODING_FOR_QUERY_STRING was messing up my application.
To be honest I'm not sure what my Body Encoding is (ISO or cp-1250) and how to change it but dropping that single option has worked like a charm.
While this is strange because I'm kind of convinced that I have UTF8 set across my application, my final conclusion is that if you get into similar problems try dropping
USE_BODY_ENCODING_FOR_QUERY_STRING from standalone.xml