Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3187

Stream result type charset

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.1.8
    • Component/s: Other
    • Labels:
      None
    • Environment:

      Struts 2.1.6, Glassfish v2.1

      Description

      Stream result type doesn't allow to set charset of the response.

      Anyway I was getting that response in UTF-8 as defined in my server config. I discovered the problem when set the default locale for my app in struts.properties. After adding "struts.locale=en_GB" I started to get the response of the stream results in ISO-8859-1 but not the data as I could point with Firebug.
      Here is the response before adding the struts.locale catched with Firebug:

      X-Powered-By Servlet/2.5
      Server Sun Java System Application Server 9.1_02
      Set-Cookie userLanguage=en_GB; Expires=Mon, 12-Oct-2009 14:25:46 GMT; Path=/
      Content-Disposition inline
      Content-Type text/plain
      Transfer-Encoding chunked
      Date Tue, 14 Jul 2009 14:25:47 GMT

      The response after adding the struts.locale:

      X-Powered-By Servlet/2.5
      Server Sun Java System Application Server 9.1_02
      Set-Cookie userLanguage=en_GB; Expires=Mon, 12-Oct-2009 14:27:35 GMT; Path=/
      Content-Disposition inline
      Content-Type text/plain;charset=ISO-8859-1
      Content-Language en-GB
      Transfer-Encoding chunked
      Date Tue, 14 Jul 2009 14:27:37 GMT

      I can solve this problem modifying my struts.xml file adding the charset after the contentType in param attribute but I think that's not the better way:

      <result type="stream" name="success">
      <param name="contentType">text/plain; charset=UTF-8</param>
      <param name="inputName">inputStream</param>
      </result>

      My workmate posted more info about it in the struts2 mail list:

      http://www.nabble.com/Stream-Result-and-Japanese-data-getting-corrupted-td22432726.html

        Attachments

          Activity

            People

            • Assignee:
              wesw@wantii.com Wes Wannemacher
              Reporter:
              kienvaser David SanmartĂ­n
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: