Shankar, Chris,

With reference to your previous posts....

(From section 3.7.1 of the HTTP/1.1 spec).

I tried a small example by not forcing the request's content type,
and was able to see the Big5 characters without any problems even
when the Request's characterEncoding was null. The code below demonstrates this.


So Tomcat is running with -Dfile.charset=Big5 (so that's the java
default charset), and just does a 'request.getParameter("foo")'. And the
value for foo in the body of the POST is "%AEx", which (again) we didn't
encode - it's IE that's doing this when you type in a Big5 char into a
text field in a form (I guess it's internally treating the raw bytes as
ISO8859-1).

"%AEx" , could be a URL Encoded Hex representation of the specific
Big5 character (not sure about it though, because decoding it doesn't
give a Big5 character but instead gives garbage characters)

Here's the example I tried, that shows the Big5 character correctly
when transmitted over HTTP GET , notice the characters in the URL
encoded parameter.

-----------------------------------------
index.jsp
-----------------------------------------

<%@ page pageEncoding="Big5" contentType="text/html; charset=Big5" %>

<html>

<head>

   <meta http-equiv="Content-Type" content="text/html; charset=Big5" />

</head>

<body>

<%
//String paramEncoding = application.getInitParameter("PARAMETER_ENCODING");
//request.setCharacterEncoding(paramEncoding);
%>

Request Character Encoding =
<%=request.getCharacterEncoding()%>



<br/><br/>

Response Character Encoding =
<%=response.getCharacterEncoding()%>


<br/><br/>

<form action="test.jsp" method="GET">
   <input type="text" name="textField" value="造字"/>
   <input type="submit" name="submit" value="submit"/>
</form>

</body>

</html>


------------------------------------------
test.jsp
------------------------------------------

<%@ page import="java.net.URLDecoder" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page pageEncoding="Big5" contentType="text/html; charset=Big5" %>

<html>

<head>

   <meta http-equiv="Content-Type" content="text/html; charset=Big5" />

</head>

<body>

<%
//String paramEncoding = application.getInitParameter("PARAMETER_ENCODING");
//request.setCharacterEncoding(paramEncoding);
%>

Request Character Encoding =
<%=request.getCharacterEncoding()%>

<br/><br/>

Response Character Encoding =
<%=response.getCharacterEncoding()%>


<br/><br/>
Text Filed Contents =
<%=request.getParameter("textField")%>

<br/><br/>

URL Encode:

<%=URLEncoder.encode("造字", "Big5")%>

<br/><br/>

URL Decode:
<%=URLDecoder.decode("%B3y%A6r", "Big5")%>

The above shows garbage characters.

</body>

</html>

---------------------------
web.xml
---------------------------

   <context-param>
       <param-name>PARAMETER_ENCODING</param-name>
       <param-value>Big5</param-value>
   </context-param>

---------------------------
Tomcat 6.x server.xml
----------------------------

   <Connector port="9090" protocol="HTTP/1.1"
              maxThreads="150" connectionTimeout="20000"
              redirectPort="8443"
               URIEncoding="Big5"/>

-Rashmi

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to