Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-30629

[GSS](7.4.z) WFLY-16584 - Servlet's default character encoding setting is not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 7.4.24.GA
    • None
    • Undertow
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • ?
    • Hide

      1. Set the following in web.xml

        <request-character-encoding>UTF-8</request-character-encoding>
        <response-character-encoding>UTF-8</response-character-encoding>
      

      2. Create a servlet like the following

      @WebServlet("/test")
      public class TestServlet extends HttpServlet {
      
          @Override
          protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
              res.setContentType("text/plain");
              PrintWriter pw = res.getWriter();
              pw.println("REQ_CHAR_ENC = " + req.getCharacterEncoding());
              pw.println("RES_CHAR_ENC = " + res.getCharacterEncoding());
          }
      }
      

      3. Running the servlet produces the following output.

      REQ_CHAR_ENC = null
      RES_CHAR_ENC = ISO-8859-1
      
      Show
      1. Set the following in web.xml <request-character-encoding> UTF-8 </request-character-encoding> <response-character-encoding> UTF-8 </response-character-encoding> 2. Create a servlet like the following @WebServlet( "/test" ) public class TestServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType( "text/plain" ); PrintWriter pw = res.getWriter(); pw.println( "REQ_CHAR_ENC = " + req.getCharacterEncoding()); pw.println( "RES_CHAR_ENC = " + res.getCharacterEncoding()); } } 3. Running the servlet produces the following output. REQ_CHAR_ENC = null RES_CHAR_ENC = ISO-8859-1

      The default encoding settings in web.xml does not work on JBoss EAP 7.4.z. This is backport request for WFLY-16584

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
               http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
               version="4.0">
          <request-character-encoding>UTF-8</request-character-encoding>
          <response-character-encoding>UTF-8</response-character-encoding>
      </web-app>
      

              lvydra Lukas Vydra
              rhn-support-nagetsum Norito Agetsuma
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: