You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2004/03/24 08:30:04 UTC

DO NOT REPLY [Bug 27893] New: - Cann't get UTF-8 parameter when set contentType="text/html;charset=UTF-8".

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=27893>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=27893

Cann't get UTF-8 parameter when set contentType="text/html;charset=UTF-8".

           Summary: Cann't get UTF-8 parameter when set
                    contentType="text/html;charset=UTF-8".
           Product: Tomcat 5
           Version: 5.0.19
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Servlet & JSP API
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: xuliang_net@163.com


I submit a utf-8 form to my jsp, and i get the parameter after
request.setCharacterEncoding("UTF-8"). It is successful when there isn't <%@page
contentType="text/html;charset=UTF-8" %> and it was failed when add  <%@page
contentType="text/html;charset=UTF-8" %>. And it can right work in tomcat 4.1.27.

My locale is zh_CN.
My request url is
"http://127.0.0.1:8080/HttpRequestDumper.jsp?to=%2B88888&from=%2B00000&data=test+%E4%BD%A0%E5%A5%BD&service=test&operator=tester&pricecode=100".

There is my html and jsp.
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
	<form name="TestHttpGatewayForm"
action="http://127.0.0.1:8080/HttpRequestDumper.jsp" method="GET" >
		<table border="1">
			<caption>TestForm<br></caption>
			<tbody>
			<tr>
				<td>to</td>
				<td><input type="text" name="to" value="+88888"></td>
			</tr>
			<tr>
				<td>from</td>
				<td><input type="text" name="from" value="+00000"></td>
			</tr>
			<tr>
				<td>data</td>
				<td><input type="text" name="data"></td>
			</tr>
			<tr>
				<td>service</td>
				<td><input type="text" name="service" value="test"></td>
			</tr>
			<tr>
				<td>operator</td>
				<td><input type="text" name="operator" value="tester"></td>
			</tr>
			<tr>
				<td>pricecode</td>
				<td><input type="text" name="pricecode" value="100"></td>
			</tr>
			<tr>
				<td><input type="submit" value="submit" title="Copy license files"></td>
			</tr>
      </tbody>
    </table>
  </form>
</body>
</html>

<%@page import="java.util.Enumeration" %>
<%@page contentType="text/html;charset=UTF-8" %>

<%
	request.setCharacterEncoding("UTF-8");
%>

<html>  
  <body bgcolor="white">
    <table id="genenal" border="1">
      <caption>Request Information<br></caption>
      <tbody>
        <tr>
          <td>JSP Request Method</td>
          <td><%= request.getMethod() %></td>
        </tr>        
        <tr>
          <td>Request Protocol</td>
          <td><%= request.getProtocol() %></td>
        </tr>
        <tr>
          <td>Server name</td>
          <td><%= request.getServerName() %></td>
        </tr>
        <tr>
          <td>Server port</td>
          <td><%= request.getServerPort() %></td>
        </tr>
        <tr>
          <td>Request URI</td>
          <td><%= request.getRequestURI() %></td>
        </tr>
        <tr>
          <td>Servlet path</td>
          <td><%= request.getServletPath() %></td>
        </tr>
        <tr>
          <td>Locale</td>
          <td><%= request.getLocale() %></td>
        </tr>
      </tbody>
    </table>

    <table id="parameters" border="1">
      <caption>Request Parameters<br></caption>
      <tbody>
      	<%
		Enumeration paramNames = request.getParameterNames();
		while (paramNames.hasMoreElements()) {
			String paramName = (String) paramNames.nextElement();
      	%>
        <tr>
          <td><%= paramName %></td>
          <td><%= request.getParameter(paramName) %></td>
        </tr>
      	<% } %>        
      </tbody>
    </table>
    <table id="headers" border="1">
      <caption>Request Headers<br></caption>
      <tbody>
      	<%
		Enumeration headerNames = request.getHeaderNames();
		while (headerNames.hasMoreElements()) {
			String headerName = (String) headerNames.nextElement();
      	%>
        <tr>
          <td><%= headerName %></td>
          <td><%= request.getHeader(headerName) %></td>
        </tr>
      	<% } %>        
      </tbody>
    </table>
  </body>
</html>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org