Pfeifer Jan wrote:
> 
> Hi,
> I am running webapp for some time with no problems. After some 
> "change" that I am not able to identify my POST (GET works fine) 
> requests are messed up. Just on my local server.

http://wiki.apache.org/tomcat/FAQ/CharacterEncoding

Mark

> 
> Some facts: Tomcat 5.0.28, jdk 1.4.2.07 winXP, (others in,xp win server,linux)
> Following simple code produces different result on my server and the others 
> (web.xml,server.xml,jdk configuration is the same)
> 
> Form page:
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
> "http://www.w3.org/TR/html4/strict.dtd">
> <html>
> <head>
>   <meta http-equiv="Content-Type" content="text/html; 
> charset=UTF-8">
>   <title>Encoding test</title>
>  
>   <script type="text/javascript">
>   function test(method){
>    var frm = document.getElementById("form");
>    frm.method = method;
>    frm.submit();
>   }
>   </script>
> </head>
> 
> <body> 
>  <form method='POST' action='post_process.jsp' id='form'>
>   <input type='text' name='param'>
>  </form> 
> 
>  <button onclick='test("get")'>get</button>
>  <button onclick='test("post");'>post</button>
> </body>
> </html>
> 
> post_procces.jsp
> <%@ page language="java" session="true" 
> contentType="text/html; charset=UTF-8"%>
> <% request.setCharacterEncoding("UTF-8");  %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
> "http://www.w3.org/TR/html4/strict.dtd">
> <html>
> <head>
>  <meta http-equiv="Content-Type" content="text/html; 
> charset=UTF-8">
>  <title>Encoding test process</title>
> </head>
> <body>
> 
>   <% String param   = request.getParameter("param");
>      String decoded = new 
> String(param.getBytes("iso-8859-1"),"UTF-8");
>   
>   System.out.println("Original value --> "+param);
>   System.out.println("Decoded  value --> "+decoded);
>   %>  
>   
>   V2<br>
>   Method: <%= request.getMethod() %><br>
>   Encoding: <%= request.getCharacterEncoding() %><br>
>   Locale: <%= request.getLocale() %><br>
>   Default System charset: <%= new java.io.OutputStreamWriter(new 
> java.io.ByteArrayOutputStream()).getEncoding() %><br>
>   Original value:  '<span style='color:<%= 
> request.getMethod().equals("GET") ? "red" : 
> "green" %>'><%= param %></span>'<br>
>   Decoded  value: '<span style='color:<%= 
> request.getMethod().equals("GET") ? "green" : 
> "red" %>'><%= decoded %></span>'<br>
>   </table>
> </body>
> </html>
> 
> My output:
> Method: POST
> Encoding: UTF-8
> Locale: cs
> Default System charset: Cp1250
> Original value: 'čížek'
> Decoded value: 'čížek'
> 
> Correct output (any other server):
> V2
> Method: POST
> Encoding: UTF-8
> Locale: cs
> Default System charset: Cp1250
> Original value: 'čížek'
> Decoded value: '?�?ek'
> 
> I spent last two days googling and looking for answer with no luck. Hope that 
> someone can help.
> 
> Thanks in advance
> Jan Pfeifer
> 
> 




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

Reply via email to