2013/8/26 Alexander Hartner <a...@j2anywhere.com>:
> This may be more of an application problem than a tomcat issue, but I am
> rather stuck with this one and hoping that somebody on this list may be
> able to shed some light on my issue.
>
> I am trying to post UTF-8 encoding text to my JSF2.2 application,
> however the data received does not seem to be encoded correctly.I
> narrowed this problem down to the weld listener. To illustrate the issue
> I modified the test page from the tomcat faq:
>
>
>
>  1. <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
>  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>  3. <html>
>  4.   <head>
>  5.     <title>Character encoding test page</title>
>  6.   </head>
>  7.   <body>
>  8.     <p>
>  9.       Encoding : <%=request.getCharacterEncoding()%>
> 10.     </p>
> 11.     <p>Data posted to this form was:
> 12.       <%
> 13.         request.setCharacterEncoding("UTF-8");
> 14.         out.print(request.getParameter("mydata"));
> 15.       %>
> 16.     </p>
> 17.     <form method="GET" action="index.jsp">
> 18.       <input type="text" name="mydata">
> 19.       <input type="submit" value="SubmitGET" />
> 20.     </form>
> 21.     <form method="POST" action="index.jsp">
> 22.       <input type="text" name="mydata">
> 23.       <input type="submit" value="SubmitPOST" />
> 24.     </form>
> 25.     .g. ç,g(,ö,s,,?, etc Soße " Test data "
> 26.   </body>
> 27. </html>
>
>
>
> So I have a simple web application which only consist of this page, and
> the weld library in WEB-INF/lib (weld-servlet-2.0.3.Final.jar).
>
> So far so good. However as soon as I include the weld listener in my
> web.xml file
>
>
>
>  1. <?xml version="1.0" encoding="UTF-8"?>
>  2.
>  3. <web-app xmlns="http://java.sun.com/xml/ns/javaee";
>  4.          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  5.          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
> http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
>  6.          version="3.0">
>  7.   <listener>
>  8.     
> <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
>  9.   </listener>
> 10.   <session-config>
> 11.     <session-timeout>
> 12.       30
> 13.     </session-timeout>
> 14.   </session-config>
> 15. </web-app>
>
>
>
> The post parameters are corrupted by the listener.
>
>
>
> I did enable URIEncoding="UTF-8" in the server.xml file, but this did
> not make any difference.
>
>  1. <Connector executor="tomcatThreadPool"
>  2.            port="8080" protocol="HTTP/1.1"
>  3.            connectionTimeout="20000"
>  4.            redirectPort="8443"
>  5.            URIEncoding="UTF-8"/>
>
>
>
> With the listener enabled data like "Soße" is received as "SoÃY"e",
> however once the listerner is removed everything works as expected.
>

1. I hope you have seen the FAQ.
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding

and
http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Set_Character_Encoding_Filter

2. Try to run with a debugger
http://wiki.apache.org/tomcat/FAQ/Developing#Debugging

with a breakpoint in org.apache.catalina.connector.Request#parseParameters()

I guess that there is some component that calls one of getParameter()
methods before your request.setCharacterEncoding("UTF-8") and thus the
default of ISO-8859-1 is effective.

3. What exact version of Tomcat 7.0.x are you using?

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to