cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Cocoon Wiki] Update of "RequestParameterEncoding" by AlexanderKlimetschek
Date Thu, 18 Jan 2007 17:37:49 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification.

The following page has been changed by AlexanderKlimetschek:

  If your Cocoon application needs to read request parameters that could contain ''special''
characters, i.e. characters outside of the first 128 ASCII characters, you'll need to pay
attention to what encoding is used.
  Normally a browser will send data to the server using the same encoding as the page containing
the submitted form (or whatever). So if the pages are serialized using UTF-8, the browser
will submit form data using UTF-8. The user can change the encoding, but it's quite safe to
assume he/she won't do that (have you ever done it?).
+ ''In my browser this is the case, it is set in the preferences to ISO-8859-1 and he encodes
form parameters with that, regardless of the UTF-8 content type of the page containing the
form. I can't remember when I did set this property... So what to do with this case? This
means, it could be any encoding.'' -- AlexanderKlimetschek
  After doing some tests with popular browsers, I've noticed that usually browsers will not
let the server know what encoding they used to encode the parameters, so we need to make sure
ourselves that the encoding used when serializing pages corresponds to the encoding used when
decoding request parameters.
@@ -47, +49 @@

  (Volkmar W. Pogatzki)''
  By default, if the browser doesn't explicitely mention the encoding, a servlet container
will decode request parameters using the ISO-8859-1 encoding (independent of the platform
on which the container is running). So in the above case where UTF-8 was used when serializing,
we would be facing problems.
+ ''Note: Jetty uses [[
UTF-8 as default for decoding form parameters]]! So you have to use the {{{SetCharacterEncodingFilter}}}
(see below) to set the encoding for Jetty to ISO-8859-1 if this is what the browser sends.''
  The encoding to use when decoding request parameters can be configured in the web.xml by
supplying init parameters called "form-encoding" and "container-encoding" to the Cocoon servlet.
The container-encoding parameter indicates according to what encoding the container tried
to decode the request parameters (normally ISO-8859-1), and the form-encoding parameter indicates
the actual encoding. Here's an example of how to specify the parameters in the web.xml:

View raw message