The following comment has been added to this issue:
Author: Chris Miller
Created: Tue, 5 Aug 2003 8:00 AM
Body:
OK, looks like we found the source of the problem.
Sitemesh grabs the response writer (using response.getWriter()) *before* my content generation filter has had a chance to set the content type and character set. However if you look at the JavaDocs for response.getWriter(), it's pretty clear that this is a bad state of affairs - the writer that sitemesh uses will end up using the default platform encoding regardless.
I'm not sure why this works with plain HTML though. My guess is because the server knows to set the content type before it calls the filter chain?
Anyway, we solved this by wrapping another filter around the outside of Sitemesh that sets the content type appropriately for the request. Not an ideal solution but I'm not sure there's any other way around it?
At the very least this behaviour needs to be clearly documented.
---------------------------------------------------------------------
View the issue:
http://jira.opensymphony.com/secure/ViewIssue.jspa?key=SIM-63
Here is an overview of the issue:
---------------------------------------------------------------------
Key: SIM-63
Summary: i18n encoding problem
Type: Bug
Status: Assigned
Priority: Major
Project: SiteMesh
Components:
Filter
Versions:
1.6.1
Assignee: Mathias Bogaert
Reporter: Chris Miller
Created: Fri, 16 May 2003 10:45 AM
Updated: Fri, 16 May 2003 10:53 AM
Environment: Latest Sitemesh CVS, Orion 2.0.1, Win2K, JDK1.4.1_02
Description:
I've hit what appears to be a Sitemesh bug relating to i18n. I have a filter that produces a UTF-8 encoded HTML page using code similar to this:
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"><title>TEST</title></head><body>");
out.println("Pound: \u20A4<br>");
out.println("Euro: \u20AC<br>");
out.println("Arabic:
\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669<br>");
out.println("</body></html>");
This output displays fine in IE normally, however if the Sitemesh filter is applied before my filter, any double/triple byte characters get turned into ? characters (regardless of whether a decorator is actually applied by Sitemesh or not). If I don't use a filter but instead serve an actual HTML page directly (but still through Sitemesh), everything works fine.
It seems that Sitemesh is ignoring the encoding specified by response.setContentType() even though I explicitly set it.
An ugly workaround is to call:
System.setProperty("file.encoding", "UTF-8");
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.opensymphony.com/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.