tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Hartner <a...@j2anywhere.com>
Subject Encoding post data on Tomcat 7 using 2.0.3 corrupted
Date Mon, 26 Aug 2013 05:40:29 GMT
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.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message