DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=31201>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=31201 Encoding bug when using <jsp:include ...> action Summary: Encoding bug when using <jsp:include ...> action Product: Tomcat 4 Version: 4.1.30 Platform: All OS/Version: All Status: NEW Severity: Major Priority: Other Component: Catalina AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] There is a bug in "JSP include" that DefaultServlet assigns default locale encoding for included file using <jsp:include file="..."> action, and the included file's encoding is not matched default locale. For example; locale=ja_JP.SJIS abc.html: written by Windows-31J page.jsp: --- <%@ page contentType="text/html; charset=Windows-31J" %> page include!! <HR> <jsp:include file="abc.html" flush="true" /> <HR> --- HTML file's encoding should be fixed when Web Application is deploying. So I tried to make a patch for this bug. I added "fileEncoding" parameter for DefaultServlet. Patch for this bug follows: =================================================================== *** DefaultServlet.java Sun Jan 25 22:23:42 2004 --- DefaultServlet_patch.java Mon Sep 13 22:13:39 2004 *************** *** 177,182 **** --- 177,187 ---- /** + * Encoding for Reader + */ + protected String fileEncoding; + + /** * MD5 message digest provider. */ protected static MessageDigest md5Helper; *************** *** 306,311 **** --- 311,322 ---- } catch (Throwable t) { ; } + try { + value = getServletConfig().getInitParameter("fileEncoding"); + fileEncoding = value; + } catch (Throwable t) { + ; + } // Sanity check on the specified buffer sizes if (input < 256) *************** *** 1793,1799 **** InputStream resourceInputStream = resourceInfo.getStream(); // FIXME : i18n ? ! Reader reader = new InputStreamReader(resourceInputStream); // Copy the input stream to the output stream exception = copyRange(reader, writer); --- 1804,1812 ---- InputStream resourceInputStream = resourceInfo.getStream(); // FIXME : i18n ? ! Reader reader = (fileEncoding == null) ? ! new InputStreamReader(resourceInputStream) : ! new InputStreamReader(resourceInputStream, fileEncoding); // Copy the input stream to the output stream exception = copyRange(reader, writer); *************** *** 1864,1870 **** IOException exception = null; InputStream resourceInputStream = resourceInfo.getStream(); ! Reader reader = new InputStreamReader(resourceInputStream); exception = copyRange(reader, writer, range.start, range.end); // Clean up the input stream --- 1877,1885 ---- IOException exception = null; InputStream resourceInputStream = resourceInfo.getStream(); ! Reader reader = (fileEncoding == null) ? ! new InputStreamReader(resourceInputStream) : ! new InputStreamReader(resourceInputStream, fileEncoding); exception = copyRange(reader, writer, range.start, range.end); // Clean up the input stream *************** *** 1956,1962 **** while ( (exception == null) && (ranges.hasMoreElements()) ) { InputStream resourceInputStream = resourceInfo.getStream(); ! Reader reader = new InputStreamReader(resourceInputStream); Range currentRange = (Range) ranges.nextElement(); --- 1971,1979 ---- while ( (exception == null) && (ranges.hasMoreElements()) ) { InputStream resourceInputStream = resourceInfo.getStream(); ! Reader reader = (fileEncoding == null) ? ! new InputStreamReader(resourceInputStream) : ! new InputStreamReader(resourceInputStream, fileEncoding); Range currentRange = (Range) ranges.nextElement(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]