Mantis - Resin
Viewing Issue Advanced Details
1083 major always 05-02-06 05:39 06-27-06 08:23
jrg745  
ferg  
normal  
closed 3.0.18  
fixed  
none    
none 3.0.20  
0001083: Encoding problem in resin jstl implementation
The jspx page below reads two files containing special characters like umlauts and the Euro character, parses them and displays the result. The first file is encoded using UTF-8, the second using ISO-8859-1. The result page uses ISO-8859-1.

The import is done using c:import, the document is parsed with x:parse and the as a result the variable that holds the original data is output using c:out and the parsed content using x:out.

If the original file is encoded as UTF-8 the result is nearly correct, only the Euro character is not displayed correctly. If the original file is encoded using ISO-8859-1 the result from c:out is correct, but the output from x:out is not readable. Surprisingly, in this case the Euro character is the only character that is displayed correctly.

We are using resin 3.0.18 under Windows XP.
The jspx code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" [^]
          xmlns:c="http://java.sun.com/jsp/jstl/core" [^]
          xmlns:x="http://java.sun.com/jsp/jstl/xml" [^]
          version="2.0">
              
<jsp:directive.page contentType="text/html; charset=ISO-8859-1"/>
  <html>
    <body>
        <h1>UTF Test</h1>
          <c:import charEncoding="UTF-8" url="http://localhost:8080/test/testUTF.xml" [^] var="docUTF"/>
          <x:parse xml="${docUTF}" var="parsedDocUTF"/>
          


            <c:out value="${docUTF}"/>
          


          


            <x:out select="$parsedDocUTF/test"/>
          


        <h1>ISO Test</h1>
            <c:import charEncoding="ISO-8859-1" url="http://localhost:8080/test/testISO.xml" [^] var="docISO"/>
            <x:parse xml="${docISO}" var="parsedDocISO"/>
            


            <c:out value="${docISO}"/>
          


            


            <x:out select="$parsedDocISO/test"/>
            


    </body>
  </html>
</jsp:root>

The test file (the ISO-8859-1 version, the test uses a second file that is encoded using UTF-8):

<?xml version="1.0" encoding="ISO-8859-1"?>
<test>
  <testtext>äöüÄÖÜ€</testtext>
</test>


Notes
(0001110)
jrg745   
05-08-06 23:43   
I now found out what really happens: in the ISO-8859-1 case, the file is imported by the c:import tag with the correct encoding. The content is stored in a string variable in Unicode format. The x:parse tag then parses this string and incorrectly applies the encoding from the encoding attribute in the xml header of the document.
The solution for the user is to encode the file in ISO-8859-1 but specify UTF-8 in the encoding attribute of the xml header. This is of course a workaround.
The correct implementation of the x:parse tag should ignore the encoding attribute because it always parses Unicode strings. So this is still a bug.
(If the charset value in the contentType attribute in the jsp is set to ISO-8859-15 even the Euro signs are displayed correctly.)
(0001313)
ferg   
06-27-06 08:23   
jsp/1cil