tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 24345] New: - request setCharacterEncoding has no affect
Date Mon, 03 Nov 2003 10:06:18 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24345>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24345

request setCharacterEncoding has no affect

           Summary: request setCharacterEncoding has no affect
           Product: Tomcat 5
           Version: 5.0.14
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: joachimz@sina.com


after update to tomcat5.0.14Beta, old page occurs some encoding issues, it 
seemed that request.setCharacterEncoding(String enc) doesn't work! Since 
request.getCharacterEncoding() is return the correct encoding that I've set
(GBK: a chinese encoding), but the String get by request.getParameter
("field_name") is still iso-8859-1! (ONLY after do like 

String newString = new String(request.getParameter("field_name")).getBytes("iso-
8859-1"), "GBK");

could get corrent String).

Following is my test JSP source:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<%@ page
	language = "java"
	session = "false"
	contentType = "text/html; charset=GBK" 
%><%request.setCharacterEncoding("GBK");%>
<HEAD>
<TITLE>Test page</TITLE>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=GBK">

<META NAME="Author" CONTENT="Joachim">
<META NAME="Keywords" CONTENT="">
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<FORM METHOD=POST ACTION="">
<TEXTAREA NAME="text" ROWS="6" COLS="60" wrap="off">
	<%=new String(cl(request.getParameter("text")).getBytes("iso-8859-
1"), "GBK")%>
</TEXTAREA>

<BR/><INPUT TYPE="submit" value="Submit">
</FORM>
<%=request.getCharacterEncoding()%>
</BODY>
</HTML>
<%!
	String cl(String v)
	{
		return (null == v) ? "" : v;
	}

%>

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


Mime
View raw message