Servlet Container and Browser's Operating Sys' locale affects how HTML form parameters are encoded/sent to browser ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Wee_Tan
Posted On:   Wednesday, May 29, 2002 08:34 PM

I have searched this forum and Sun Java Developer Connection, plus read some chapters from Jason Hunter's book (2nd Edition) on I18N. I hope somebody can clarify my questions and help to give a clue to the problem I am facing. My Servlet engine (Websphere 4.0) is installed on a English Solaris 8 OS. The web application supports browsers whose OS will be in Chinese, Japanese, English etc. HTML form input is passed from these browsers to the servlet. The relevant code snippets I have are : res.setContentType("text/html; charset=UTF-8"); String mystr = req.getParameter("mystr"); if (mystr==null) mystr=&   More>>


			
I have searched this forum and Sun Java Developer
Connection, plus read some chapters from Jason Hunter's
book (2nd Edition) on I18N. I hope somebody can clarify my
questions and help to give a clue to the problem I am
facing.

My Servlet engine (Websphere 4.0) is installed on a English
Solaris 8 OS. The web application supports browsers whose
OS will be in Chinese, Japanese, English etc. HTML form
input is passed from these browsers to the servlet.

The relevant code snippets I have are :

res.setContentType("text/html; charset=UTF-8");

String mystr = req.getParameter("mystr");
if (mystr==null)
mystr="";
mystr = new String(mystr.getBytes("ISO-8859-1"),"UTF-8");

The JSP page that contains the form is encoded in UTF-8, and has a


charset=UTF-8">

metatag and has a

response.setContentType("text/html; charset=UTF-8");

scriptlet code as well.

The code sample works (ie I can display the the Chinese
text that I entered thro the HTML input field in the JSP)
if the locale of the browser's OS is English (US). But when
I change the locale (I am running Windows 2000 OS - changed
locale by using control panel). to Chinese (Taiwan), ??? is
displayed.

My questions are :

1) Are the parameters sent to the servlet from the web page
always in single byte ISO-8859-1 encoding ?

2) If the browser's OS locale is not English ? How are the
HTML form parameters encoded and passed to the servlet ?

3) When we read the HTTP header from the request (to our
servlet), we saw that the Accept-Language header was zh-tw.
In this case does it mean that the browser has sent the
parameters in Big5 encoding ?

4) Does the web container and the OS that the web container
is hosted (Websphere 4.0 and Solaris 8 English version)
make a difference ?

Thanks in advance for your help

Regards
   <<Less

Re: Servlet Container and Browser's Operating Sys' locale affects how HTML form parameters are encoded/sent to browser ?

Posted By:   Mehul_Jasani  
Posted On:   Monday, July 1, 2002 07:07 PM

Hi Wee,

Did you got any answer, even I have similar problem, and not getting any clue.

BTW, If you are using servlet 2.3 , then it has setCharacterEncoding(), which you can call on request, before any getparameter() is called in your jsp/servlet code.

It works, i have checked that in tomact 4.x, but I have to do it with tomcat 3.2.1, and it supports servlet2.2, which does not have setcharacterencoding() method.

Regards,
Mehul.
About | Sitemap | Contact