Garbled characters happen when raw multibytes characters exist in POST request data with application/x-www-form-urlencoded content-type in JBoss EAP 7

Solution Unverified - Updated -

Issue

A garbled character issue happens when a client application sends a POST request data with raw multibyte characters as application/x-www-form-urlencoded content-type to JBoss EAP 7. The same request does not face such a garbled character issue with JBoss EAP 6 or Tomcat.

example application:

...(snip)...
@WebServlet(name = "TestServlet", urlPatterns = {"/test"})
public class TestServlet extends HttpServlet {
    ...(snip)...

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
           out.println("test = " + request.getParameter("test"));
        }
    }

result:

  • JBoss EAP 7:
$ curl http://localhost:8080/example/test -d "test=テスト"
test =  ̄テニ ̄ツᄍ ̄テネ 
  • JBoss EAP 6 and JWS 5 Tomcat 9
$ curl http://localhost:8080/example/test -d "test=テスト"
test = テスト

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content