Results 1 to 6 of 6

Thread: Problem with AjaxResponseSender and UTF-Encoding

  1. #1
    Join Date
    May 2007
    Location
    Munich
    Posts
    25

    Default 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. #2
    Join Date
    Jul 2006
    Location
    Rome, Italy
    Posts
    347

    Default

    Quote 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.
    Sergio Bossa
    Spring Modules Team

  3. #3
    Join Date
    May 2007
    Location
    Munich
    Posts
    25

    Default

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

  4. #4
    Join Date
    May 2007
    Location
    Munich
    Posts
    25

    Default

    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

  5. #5
    Join Date
    Jul 2006
    Location
    Rome, Italy
    Posts
    347

    Default

    Quote 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.
    Sergio Bossa
    Spring Modules Team

  6. #6
    Join Date
    May 2007
    Location
    Munich
    Posts
    25

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •