On Aug 26, 2013, at 1:40 AM, Alexander Hartner <[email protected]> wrote:
> 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");
What if you remove line #13? I don't think you should need to do this. The
request's character encoding should be set based on the "Content-Type" header.
If not specified it defaults to ISO-8859-1.
https://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q1
> 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"/>
This option only affects the URI, not posted data.
"This specifies the character encoding used to decode the URI bytes, after
%xx decoding the URL. If not specified, ISO-8859-1 will be used."
https://tomcat.apache.org/tomcat-7.0-doc/config/http.html
>
> With the listener enabled data like "Soße" is received as "SoÃY"e",
> however once the listerner is removed everything works as expected.
If this is actually a problem with the listener, you would have better luck
posting to the weld / listener's mailing list.
Dan
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]