What about using a Filter for setting the encoding ?

public void doFilter(ServletRequest srequest, ServletResponse sresponse,
FilterChain chain)
      throws IOException, ServletException
  {
   srequest.setCharacterEncoding("UTF-8");

    chain.doFilter(srequest, sresponse);
  }

Michael

-----Original Message-----
From: Rene Pirringer [mailto:[EMAIL PROTECTED] 
Sent: Mittwoch, 3. Oktober 2007 11:57
To: [email protected]
Subject: Post request encoding problem

Hi,

in the project I'm working on we have the problem that when we try to  
submit a form that contains german umlauts the string in the backing  
bean is not encoded correctly.
All our sites are in UTF-8 an in the post request the parameters are  
also send url encoded in UTF-8.
I debugged this and found out that the default encoding of post  
parameters that tomcat (5.5.x) uses is ISO-8859-1, and this is the  
reason for the wrong encoding. The only way to tell tomcat
to use UTF-8 is to set the enctype at the form tag to 'application/x- 
www-form-urlencoded;charset=UTF-8'
I have tested this with a header modify plugin with firefox that  
overrides this parameter.
Now I can add to every <h:form> tag the enctype, but it does not work  
for me, because JSF adds form tags itself when for example a  
commandLink is rendered, an then the charset is not set.

At my point of view the cleanest solution would be, to override the  
enctype that is defined in the standard-faces-config.xml of myfaces  
(I use version 1.1.5).
So is it possible to override this value?

Another solution is to write a custom renderer for the form tag. But  
I would prefer the first option.

Rene

Reply via email to