users@glassfish.java.net

Re: why the default response character encoding must be ISO-8859-1?

From: Ken--_at_newsgroupstats.hk <dragonken_at_gmail.com>
Date: Wed, 18 Mar 2009 10:32:18 -0700 (PDT)

[utf8-test1.jsp]

<%_at_page contentType="text/html"%>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=utf-8">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<title>Test Page for Tomcat UTF-8</title>
</head>
<body>
<pre>
content type = <%=response.getCharacterEncoding()%>
<%

// all content of my webapps are come from properties file or database. They
are in iso-8859-1 encoding
byte b[] = {-24, -69, -115, -26, -108, -65, -24, -80, -73};
String str = new String(b, "iso-8859-1");

out.print("Chinese words : ");
out.println(str);
%>
</pre>
</body>
</html>




[utf8-test2.jsp]
<%_at_page contentType="text/html;charset=utf8"%>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=utf-8">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<title>Test Page for Tomcat UTF-8</title>
</head>
<body>
<pre>
content type = <%=response.getCharacterEncoding()%>
<%

// all content of my webapps are come from properties file or database. They
are in iso-8859-1 encoding
byte b[] = {-24, -69, -115, -26, -108, -65, -24, -80, -73};
String str = new String(b, "iso-8859-1");

// with gf3, I have to convert all iso-8859-1 string to utf-8
str = new String(str.getBytes("iso-8859-1"), "utf-8");

out.print("Chinese words : ");
out.println(str);
%>
</pre>
</body>
</html>


-- 
View this message in context: http://www.nabble.com/why-the-default-response-character-encoding-must-be-ISO-8859-1--tp22562986p22584315.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.