You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Gautam Joshi (jgautam)" <jg...@cisco.com> on 2008/07/08 08:26:58 UTC

Problem with setCharacterEncoding

We are trying to set character encoding to UTF-8 in the request object
(org.apache.catalina.connector.RequestFacade) to ensure that the Danish
and some other characters are
processed correctly. 
 
We observed however that just using request.setCharacterEncoding(
encoding ) does not work and the Danish characters are converted to
question marks.
However when you add the line Enumeration e =
request.getParameterNames() before request.getParameterNames() the
encoding works and the original characters submitted from 
the form are retained. The request object is an instance of
org.apache.catalina.connector.RequestFacade. 
 
Has anyone come accross this problem and does anyone know why accessing
the method request.getParameterNames enables the character encoding to
work appropriately?
 
Thanks
Gautam

Re: Problem with setCharacterEncoding

Posted by Joerg Heinicke <jo...@gmx.de>.
On 08.07.2008 08:26, Gautam Joshi (jgautam) wrote:

> We are trying to set character encoding to UTF-8 in the request object
> (org.apache.catalina.connector.RequestFacade) to ensure that the Danish
> and some other characters are
> processed correctly. 
>  
> We observed however that just using request.setCharacterEncoding(
> encoding ) does not work and the Danish characters are converted to
> question marks.
> However when you add the line Enumeration e =
> request.getParameterNames() before request.getParameterNames() the
> encoding works and the original characters submitted from 
> the form are retained. The request object is an instance of
> org.apache.catalina.connector.RequestFacade. 
>  
> Has anyone come accross this problem and does anyone know why accessing
> the method request.getParameterNames enables the character encoding to
> work appropriately?

That's how it works. You MUST set character encoding BEFORE accessing 
request parameters. IIRC that's what form-encoding parameter is 
therefore with which Cocoon ensures that. See Cocoon's web.xml.

Joerg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org