servlet-spec
  1. servlet-spec
  2. SERVLET_SPEC-10

Character encoding setting after ServletResponse#reset

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      From javadoc, ServletResponse#reset will clear any data that exists in the buffer as well as the status code and headers. If the response has been committed, this method throws an IllegalStateException.

      Once the headers are cleared, so is the charset in Content-Type.
      If the getWriter() is already called, then according to javadoc of ServletResponse#setCharacterEncoding, one cannot set the encoding. In other words, only the default charset (in a given implementation) can used in this case.

        Activity

        Hide
        markt_asf added a comment -

        I assume that the proposed solution is that calling reset() also resets whatever tracking mechanism is used to determine that getWriter() or getOutputStream() has been called and thereby allowing the user to effectively start again.

        Show
        markt_asf added a comment - I assume that the proposed solution is that calling reset() also resets whatever tracking mechanism is used to determine that getWriter() or getOutputStream() has been called and thereby allowing the user to effectively start again.
        Hide
        Shing Wai Chan added a comment -

        If we reset the state for determining whether getWriter() and getOutputStream() has been called, then we need to clarify what happens to existing Writer or OutputStream. Then we need to clarify the behaviors of the existing writer or outputstream.

        Show
        Shing Wai Chan added a comment - If we reset the state for determining whether getWriter() and getOutputStream() has been called, then we need to clarify what happens to existing Writer or OutputStream. Then we need to clarify the behaviors of the existing writer or outputstream.
        Hide
        markt_asf added a comment -

        The spec should state that if the response is reset the Writer/OutputStream should no longer be used. Behaviour if there are used is undefined / throws ISE (I have have a slight preference for undefined since that means less work for me ).

        As it happens, Tomcat will happily allow the Writer or OutputStream to be re-used although getWriter(), reset(), getOutputStream() will allow the Writer and OutputStream to be used together which might lead to some strange results.

        Mark

        Show
        markt_asf added a comment - The spec should state that if the response is reset the Writer/OutputStream should no longer be used. Behaviour if there are used is undefined / throws ISE (I have have a slight preference for undefined since that means less work for me ). As it happens, Tomcat will happily allow the Writer or OutputStream to be re-used although getWriter(), reset(), getOutputStream() will allow the Writer and OutputStream to be used together which might lead to some strange results. Mark
        Hide
        Shing Wai Chan added a comment -

        Sending javax.servlet/src/main/java/javax/servlet/ServletResponse.java
        Transmitting file data .
        Committed revision 52096.

        Sending responseobject.fm
        Sending status.fm
        Transmitting file data ..
        Committed revision 6.

        Show
        Shing Wai Chan added a comment - Sending javax.servlet/src/main/java/javax/servlet/ServletResponse.java Transmitting file data . Committed revision 52096. Sending responseobject.fm Sending status.fm Transmitting file data .. Committed revision 6.

          People

          • Assignee:
            Shing Wai Chan
            Reporter:
            Shing Wai Chan
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: