Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Problem with AjaxResponseSender and UTF-Encoding Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with AjaxResponseSender and UTF-Encoding

    Hi,
    in AjaxResponseSender.sendResponse, l. 41, the rendered response is written into the output stream of the httpResponse the following way:

    ServletOutputStream out = httpResponse.getOutputStream();
    out.print(response);

    In my tests, if responses are written in this way, the encoding of the response is not considered - rather, all characters that can not be interpreted in ISO 8859-1, lead to the following exception:

    java.io.CharConversionException: Not an ISO 8859-1 character:
    at javax.servlet.ServletOutputStream.print(ServletOut putStream.java:89)
    at org.springmodules.xt.ajax.util.AjaxResponseSender. sendResponse(AjaxResponseSender.java:42)
    at org.springmodules.xt.ajax.AjaxInterceptor.postHand le(AjaxInterceptor.java:250)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:845)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:774)

    However, if I use the response's writer instead of its OutputStream, the encoding (UTF-8, in my case) is correctly considered:

    PrintWriter writer = response.getWriter();
    writer.print(response);

    => Should the code in AjaxResponseSender be changed to use the writer instead of the OutputStream?
    Tanks for any suggestions,
    Heiko

  • #2
    Originally posted by Heiko View Post
    => Should the code in AjaxResponseSender be changed to use the writer instead of the OutputStream?
    Hi Heiko,

    you are right: the PrintWriter is the preferred way for sending textual data, so the AjaxResponseSender must be changed.

    Do you mind opening a Jira issue about that?

    Thanks,
    Cheers,

    Sergio B.

    Comment


    • #3
      Hi Sergio,
      I just opened an issue: MOD-390
      Regards,
      Heiko

      Comment


      • #4
        Hi Sergio,
        can you already estimate when this bug is going to be fixed? Our application is throwing a lot of RuntimeExceptions currently because there are some UTF-8-characters in our database...
        Sincerely,
        Heiko

        Comment


        • #5
          Originally posted by Heiko View Post
          can you already estimate when this bug is going to be fixed?
          I'm going to fix it, so you should have it in an hour or so

          Cheers,

          Sergio B.

          Comment


          • #6
            Hi Sergio,
            thanks for the fix.
            It works fine now.
            Sincerely,
            Heiko

            Comment

            Working...
            X