Try compiling and running this in your production environment to see what your defaultCharset is set to. As far as I can tell, there is NO way to modify it after the JVM has started up.
import java.nio.charset.Charset; public class charset { public static void main(String[] args) { System.out.println(Charset.defaultCharset().displayName()); } } On 5/5/06, Sam Gendler <[EMAIL PROTECTED]> wrote:
Have you guys tried just using "-Dfile.encoding=UTF-8" when you run the jvm which will run your app server (include it in JAVA_OPTS if you run tomcat). That causes java to use UTF-8 as the charset for all incoming and outgoing content by default. Otherwise, you have to explicitly set the charset for every Reader and Writer you use, which is impossible to do without re-writing large chunks of Tapestry itself. I haven't had any issues with non-ascii characters in either direction since I added that to my JAVA_OPTS and I had plenty of problems before because the default charset in java on OS X was MacRoman rather than UTF-8. --sam On 5/5/06, Brian Long <[EMAIL PROTECTED]> wrote: > Hi Lubos, > > I received your suggested 'filter' solution a couple of months ago in > response to a problem I was having with tapestry and UTF-8, I didn't use it > afterwards as I just used an image instead of the desired text, but now that > I'm internationalising my web application, I'd like to fix this problem for > once and for all. > > I've tried/attempted your solution, but to no avail, perhaps you could take > a quick look at my implementation and check to see that I haven't done > something stupid! > > Regards, Brian. > > In web.xml (just the relevant entries are shown) > <web-app> > <context-param> > <param-name>PARAMETER_ENCODING</param-name> > <param-value>UTF-8</param-value> > </context-param> > > <filter> > <filter-name>meta-filter</filter-name> > <filter-class>com.mycompany.MetaFilter</filter-class> > </filter> > > <filter-mapping> > <servlet-name>my_project</servlet-name> > <filter-name>meta-filter</filter-name> > </filter-mapping> > > <servlet-mapping> > <servlet-name>my_project</servlet-name> > <url-pattern>/app</url-pattern> > </servlet-mapping> > > </web-app> > > The filter class I created based on your example . . . > > > package com.mycompany; > > import java.io.IOException; > > import javax.servlet.Filter; > import javax.servlet.FilterChain; > import javax.servlet.FilterConfig; > import javax.servlet.ServletException; > import javax.servlet.ServletRequest; > import javax.servlet.ServletResponse; > import javax.servlet.http.HttpServletRequest; > > public class MetaFilter implements Filter { > > FilterConfig config; > > public void init(FilterConfig config) > { > this.config = config; > } > > public void doFilter(ServletRequest servletRequest, ServletResponse > servletResponse, > FilterChain filterChain) throws IOException, > ServletException { > try { > HttpServletRequest httpServletRequest = > (HttpServletRequest) > servletRequest; > servletRequest.setCharacterEncoding("UTF-8"); > servletResponse.setContentType( "text/html; > charset=UTF-8" ); > } finally { > //do nothing; > } > } > > public void destroy() { > > } > > > } > > I'm sure I missing something in the above, the httpServletRequest I create > is never read/used, perhaps you could give me some pointers as to how I > would finish off this class? > > Thanks again for all your help . . . > > On 1/31/06, Lubos and Alena Pochman <[EMAIL PROTECTED]> wrote: > > > > I had the same problem with Tapestry 3.02 and I think it is still in 4.0. > > Somehow > > Tapestry doesnt' set up content type properly. Looking at html source from > > Tapestry, > > the <meta> for content type is not the first <meta> but the second <meta> > > in > > the <header>. > > I have read somewhere, that content type <meta> must be the first in > > <header> otherwise it is ignore. > > > > I came with workaround. I use web-app <filter> and in that I force utf-8: > > > > public void doFilter(ServletRequest servletRequest, ServletResponse > > servletResponse, > > FilterChain filterChain) throws IOException, ServletException > > { > > try { > > HttpServletRequest httpServletRequest = (HttpServletRequest) > > servletRequest; > > servletRequest.setCharacterEncoding("UTF-8"); > > servletResponse.setContentType( "text/html; charset=UTF-8" ); > > > > > > It is ugly but it works. > > > > Lubos > > > > > >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]