You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Helmut Ackermann <he...@wtnet.de> on 2004/06/16 13:30:23 UTC

trouble with request.setCharacterEncoding('UTF-8')

Dear CoCoon Developer,

I like to use Your nice java/xml-framework for my WebApplication

My system is: Microsoft Windows XP
Servlet Container: Tomcat 4.1.30
Cocoon Version: cocoon-2.1.4

I have a jsp-page that creates a html-form everything UTF-8 encoded.
Now I want to read the request parameter (send with method post) UTF-8
encoded, but
it seems that the paramters fetched within the jsp and some helper java
classes
will always use the ISO-8859-1 encoding to transform the request data into
java strings.

Now I tried to set 
'container-encoding' (init-parm in cocoon's web.xml) to UTF-8
and
'form-encoding' (init-parm in cocoon's web.xml) to UTF-8

but it seems to have no effect.
(The tcpmon of the axis group shows that the posted parameter values from
the browser are indead UTF-8 encoded)

In addition before and after calling
'request.setCharacterEncoding("UTF-8");'
the method 'request.getCharacterEncoding();'
always returns 'null' - strange isn't it
The java class behind the request seems to be
'org.apache.cocoon.components.jsp.JSPEngineServletRequest'

Please help me, is there any other parameter, which I have overlooked for
reading UTF-8 endoded form values. Why is it possible that the
CharacterEncoding is null after setting explicitly?

Yours sincerly
Dr. Helmut Ackermann
Intranet Technologien
Lütjenburger Weg 26
D 22846 Norderstedt




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


Re: trouble with request.setCharacterEncoding('UTF-8')

Posted by Joerg Heinicke <jo...@gmx.de>.
On 16.06.2004 13:30, Helmut Ackermann wrote:

> I have a jsp-page that creates a html-form everything UTF-8 encoded.
> Now I want to read the request parameter (send with method post) UTF-8
> encoded, but it seems that the paramters fetched within the jsp and
 > some helper java classes will always use the ISO-8859-1 encoding
 > to transform the request data into java strings.

Yes, ISO-8859-1 is the default behaviour.

> Now I tried to set 
> 'container-encoding' (init-parm in cocoon's web.xml) to UTF-8

You must not set this, this has to be ISO-8859-1.

> and
> 'form-encoding' (init-parm in cocoon's web.xml) to UTF-8

This is the correct one to change the behaviour.

> but it seems to have no effect.

I don't know exactly if the access from JSP to the request object 
directly the above configuration has effect or if it is just for Cocoon 
internally. You can test it for example using the RequestGenerator.

> In addition before and after calling
> 'request.setCharacterEncoding("UTF-8");'
> the method 'request.getCharacterEncoding();'
> always returns 'null' - strange isn't it

Before: No, that's not strange. That's a known behaviour of all recent 
browsers, they don't set the header.

> The java class behind the request seems to be
> 'org.apache.cocoon.components.jsp.JSPEngineServletRequest'

After: Yes, that's strange. Looking at the source [1], last method, you 
see that the encoding is not set in the wrapper. I don't know why it was 
done that way. Maybe because for avoiding wrong settings. I.e. when 
setting only 'form-encoding' correctly it maybe works and with setting 
it via setCharacterEncoding() you might break it again.

> Please help me, is there any other parameter, which I have overlooked for
> reading UTF-8 endoded form values.

No, probably only one to much :)

Joerg

[1] 
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/components/jsp/JSPEngineServletRequest.java?rev=1.2&view=markup

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