glassfish
  1. glassfish
  2. GLASSFISH-3551

request.setCharacterEncoding from JSP page must be honored at all times regardless of server's log level.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 9.0pe
    • Fix Version/s: 9.1pe_dev
    • Component/s: web_container
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Sun

    • Issuezilla Id:
      3,551

      Description

      When the JSP page calls setCharacterEncoding on request as follows,
      setCharacterEncoding is ignored when the debug is enabled in the server
      <%
      request.setCharacterEncoding("Shift-JIS");
      String str = "\u7528\u6237\u540d";
      String name = request.getParameter("name");
      %>

      When the debug is enabled in the server, in JspServlet.java's service method,
      the following code gets executed and request parameters are read
      if (log.isDebugEnabled()) {
      StringBuffer msg = new StringBuffer();
      msg.append("JspEngine --> [" + jspUri);
      msg.append("] ServletPath: [" + request.getServletPath());
      msg.append("] PathInfo: [" + request.getPathInfo());
      msg.append("] RealPath: [" + context.getRealPath(jspUri));
      msg.append("] RequestURI: [" + request.getRequestURI());
      msg.append("] QueryString: [" + request.getQueryString());
      msg.append("] RequestParams: [");
      Enumeration e = request.getParameterNames();
      while (e.hasMoreElements())

      { String name = (String) e.nextElement(); msg.append(" " + name + "=" + request.getParameter(name)); }

      msg.append(" ]");
      log.debug(msg);
      }

      With the fix for BT CR 4936855, setCharacterEncoding() has no effect if the
      request parameters are read or the input is read using getReader() prior to
      calling this method

      As a result, the servlet container logs the following warning and disregards
      setCharacterEncoding call on the request.
      "PWC4011: Unable to set request character encoding to Shift-JIS from context
      /i18njsp, because request parameters have already been read, or
      ServletRequest.getReader() has already been called"

      request.setCharacterEncoding from JSP page must be honored at all times
      regardless of server's log level.

        Activity

        Hide
        kmeduri added a comment -

        Suggested fix:
        --------------
        Index: JspServlet.java
        ===================================================================
        RCS file:
        /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v
        retrieving revision 1.13.6.2
        diff -8 -u -r1.13.6.2 JspServlet.java
        — JspServlet.java 9 Nov 2006 03:31:58 -0000 1.13.6.2
        +++ JspServlet.java 28 Aug 2007 22:22:15 -0000
        @@ -337,24 +337,16 @@
        if (log.isDebugEnabled()) {
        StringBuffer msg = new StringBuffer();
        msg.append("JspEngine --> [" + jspUri);
        msg.append("] ServletPath: [" + request.getServletPath());
        msg.append("] PathInfo: [" + request.getPathInfo());
        msg.append("] RealPath: [" + context.getRealPath(jspUri));
        msg.append("] RequestURI: [" + request.getRequestURI());
        msg.append("] QueryString: [" + request.getQueryString());

        • msg.append("] RequestParams: [");
        • Enumeration e = request.getParameterNames();
        • while (e.hasMoreElements()) { - String name = (String) e.nextElement(); - msg.append(" " + name + "=" - + request.getParameter(name)); - }
        • msg.append(" ]");
          log.debug(msg);
          }
        Show
        kmeduri added a comment - Suggested fix: -------------- Index: JspServlet.java =================================================================== RCS file: /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v retrieving revision 1.13.6.2 diff -8 -u -r1.13.6.2 JspServlet.java — JspServlet.java 9 Nov 2006 03:31:58 -0000 1.13.6.2 +++ JspServlet.java 28 Aug 2007 22:22:15 -0000 @@ -337,24 +337,16 @@ if (log.isDebugEnabled()) { StringBuffer msg = new StringBuffer(); msg.append("JspEngine --> [" + jspUri); msg.append("] ServletPath: [" + request.getServletPath()); msg.append("] PathInfo: [" + request.getPathInfo()); msg.append("] RealPath: [" + context.getRealPath(jspUri)); msg.append("] RequestURI: [" + request.getRequestURI()); msg.append("] QueryString: [" + request.getQueryString()); msg.append("] RequestParams: ["); Enumeration e = request.getParameterNames(); while (e.hasMoreElements()) { - String name = (String) e.nextElement(); - msg.append(" " + name + "=" - + request.getParameter(name)); - } msg.append(" ]"); log.debug(msg); }
        Hide
        kmeduri added a comment -

        PWC12Dev_Branch check-in:
        -------------------------

        Checking in JspServlet.java;
        /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v
        <-- JspServlet.java
        new revision: 1.13.6.3; previous revision: 1.13.6.2
        done

        Show
        kmeduri added a comment - PWC12Dev_Branch check-in: ------------------------- Checking in JspServlet.java; /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v <-- JspServlet.java new revision: 1.13.6.3; previous revision: 1.13.6.2 done
        Hide
        kmeduri added a comment -

        PWC12Dev_Branch check-in (Appended "]" to the debug message):

        Checking in JspServlet.java;
        /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v
        <-- JspServlet.java
        new revision: 1.13.6.4; previous revision: 1.13.6.3
        done

        Show
        kmeduri added a comment - PWC12Dev_Branch check-in (Appended "]" to the debug message): Checking in JspServlet.java; /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v <-- JspServlet.java new revision: 1.13.6.4; previous revision: 1.13.6.3 done
        Hide
        jluehe added a comment -

        Trunk:

        Checking in JspServlet.java;
        /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v
        <-- JspServlet.java
        new revision: 1.17; previous revision: 1.16
        done

        SJSAS91_FCS_BRANCH:

        Checking in JspServlet.java;
        /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v
        <-- JspServlet.java
        new revision: 1.16.6.1; previous revision: 1.16
        done

        Show
        jluehe added a comment - Trunk: Checking in JspServlet.java; /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v <-- JspServlet.java new revision: 1.17; previous revision: 1.16 done SJSAS91_FCS_BRANCH: Checking in JspServlet.java; /cvs/glassfish/appserv-webtier/src/java/org/apache/jasper/servlet/JspServlet.java,v <-- JspServlet.java new revision: 1.16.6.1; previous revision: 1.16 done
        Hide
        gfbugbridge added a comment -

        <BT6599012>

        Show
        gfbugbridge added a comment - <BT6599012>

          People

          • Assignee:
            jluehe
            Reporter:
            kmeduri
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: