FG Soft

JBoss and UTF-8 in Query String

A frequent issue for us with our swedish åäö characters are problems related to encoding and requests to server where UTF-8 is used as the character encoding for sending requests is how to deal with it on the server.

The easy part is to make sure all requests are posting as UTF-8.

The tricky part is to remember to configure JBoss to interpret the requests as UTF-8. This can be done in the configuration file server/default/deploy/jboss-web.deployer/server.xml

Set the URI encoding to "UTF-8" will solve the problem and all parameters in the query string will be parsed as UTF-8 instead of default which often is ISO-8859-1.

    <Connector port="8080" address="${jboss.bind.address}"    
         maxThreads="250" maxHttpHeaderSize="8192"
         emptySessionPath="true" protocol="HTTP/1.1"
         enableLookups="false" redirectPort="8443" acceptCount="100"
         connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8" />

This will resolve the problem with the URL like

http://localhost:8080/articles/12887-Många-gillar-månfärder-i-mörker

http://localhost:8080/articles?id=12887&title=Många+gillar+månfärder+i+mörker

After changing the setting, the code below in a JSP-page will work

<%="Title=" + request.getParameter("title"))%>

Output from the JSP snipplet

Title=Många gillar månfärder i mörker

Thank you for visiting my blog!

//Fredrik

Add your comment

Your name:
Your email:
Your website:
Subject:
Comment:

About the Author

This blog is written by Fredrik Gustavsson, Boden, Sweden. I have been into professional software development since 1989 and have seen what has happened over the years.

With this blog, I will share my experiences when developing for the "Cloud" comparing the Google and Microsoft solutions