Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-16584

Servlet's default character encoding setting is not working.

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Web (Undertow)
    • None
    • 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
    • ---
    • ---

    Description

      The default character encoding setting in web.xml added in Servlet 4.0 is not working.

      Attachments

        Activity

          People

            flaviarnn Flavia Rainone
            fukumotyo Hisaya FUKUMOTO (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: