Hello Bruno,
Thank you so much for your help. I've got it working now! Sorry I didn't
respond earlier.
On Wed, Feb 15, 2006 at 09:28:17AM +0100, Bruno Dumon wrote:
[...]
>
> I have had the same experience. While request parameters and post-bodies
> are decoded correctly, the URL path itself is not.
After reading this, I thought I could solve the problem by moving the Arabic
text to a request parameter. You've suggested this solution too in a private
message to me. But this didn't work.
>
> This can be fixed though.
>
> If you are running Jetty, supply the following parameter to the java
> command line:
> -Dorg.mortbay.util.URI.charset=UTF-8
>
> If you are running Tomcat, you can do the same by editing
> conf/server.xml, and on the Connector element (for http), add the
> attribute URIEncoding="UTF-8".
I'm using Tomcat 5.0. I have multiple connectors for virtual hosts. This
attribute must be set for every connector.
>
> Now, this will make that URL paths are correctly decoded as UTF-8.
> However, this also means that request parameters will be decoded as
> UTF-8, while Cocoon normally supposes the servlet container decodes them
> as ISO-8859-1 and then corrects this itself.
>
> The solution I have is to add a servlet filter which will set the
> character encoding to UTF-8. Here's the source for such a filter:
>
> package my;
>
> import javax.servlet.*;
> import java.io.IOException;
>
> public class CharacterEncodingFilter implements Filter {
> private String encoding;
>
> public void init(FilterConfig filterConfig) throws ServletException {
> encoding = filterConfig.getInitParameter("encoding");
> }
>
> public void doFilter(ServletRequest servletRequest, ServletResponse
> servletResponse, FilterChain filterChain) throws IOException,
> ServletException {
> if (servletRequest.getCharacterEncoding() == null && this.encoding !=
> null) {
> servletRequest.setCharacterEncoding(this.encoding);
> }
> filterChain.doFilter(servletRequest, servletResponse);
> }
>
> public void destroy() {
> }
> }
>
> Compile this, put it in a jara, put in in WEB-INF/lib. Edit the web.xml
> file and add the following before the opening <servlet> element:
>
> <filter>
> <filter-name>encoding-filter</filter-name>
> <filter-class>my.CharacterEncodingFilter</filter-class>
> <init-param>
> <param-name>encoding</param-name>
> <param-value>UTF-8</param-value>
> </init-param>
> </filter>
>
> <filter-mapping>
> <filter-name>encoding-filter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> In the same web.xml file, adjust both the form-encoding and
> container-encoding parameters to be UTF-8 (these elements are already
> there, don't add new ones):
>
> <init-param>
> <param-name>container-encoding</param-name>
> <param-value>UTF-8</param-value>
> </init-param>
>
> <init-param>
> <param-name>form-encoding</param-name>
> <param-value>UTF-8</param-value>
> </init-param>
At first cocoon didn't work after this. But your suggestion in a private
message to me was right. The class wasn't located in the right directory in
the jar. I uses javac and jar here and not Eclipse or Maven.
>
> (The container-encoding is now UTF-8 since the filter has instructed the
> container to decode everything as UTF-8, while per default it will use
> ISO-8859-1. This is needed because we otherwise can't destinguish
> between the UTF-8 decoded URL and the ISO-8859-1 decoded post body)
>
> And this should make everything working correctly.
It does!
>
> BTW, I have found out all this only very recently and will take up the
> discussion on the dev list to make this the default in Cocoon.
Please do. I think Cocoon should use UTF-8 wherever possible.
شكراً
= Shukran
= Thank you
Fred Vos
--
|E R
| D F
|
|fred at fredvos dot org
|5235 DG 52 NL +31 73 6411833
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]