Here is the problem...
If you send and HTML form UTF-8 encoded to most clients (IE and Netscape,
for example), you will receive UTF-8 in response. The trouble is, there is
nothing (no HTTP header) that tells the servlet container what the encoding
is. Most will attempt to guess based on the "Accept-Language" header, and
in the case of Japanese, will guess Shift_JIS, ISO-2022-JP, or EUC-JP. To
add insult to injury, Internet Explorer 5.0 and 5.5 have two bugs that make
this even harder....
1) When doing a POST with or without parameters or a GET without parameters,
IE will only send the Accept-Language header on the first request. After
that, no header is sent and the container will probably default to
ISO-8859-1 (Latin-1)
2) If you have done a client-side transformation to get your HTML form, IE
5.0 and 5.5 will usually, and incorrectly, send empty parameters as a UTF-8
encoded null, which will almost certainly cause you problems.
If you can avoid problem #2, then try this to correct the encoding:
String encoding = request.getCharacterEncoding();
if (encoding == null)
{
encoding = "ISO-8859-1";
}
String param = request.getParameter("param");
if ((param != null) && !(param.equals("")))
{
// Ensure the correct character encoding
param = new String(param.getBytes(encoding), "UTF8");
}
If you are trying to i18nize your app, and you use POST, you will also have
to cache the correct Accept-Language in the session to avoid the IE 5 bug.
Servlets 2.3 will have a HTTPServletRequest wrapper object that will make
that code easier to do on a large scale.
Hope this helps,
Mark
-----Original Message-----
From: Juan Gargiulo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 3:01 PM
To: [EMAIL PROTECTED]
Subject: form in UTF-8 doesn't work with weblogic
Hi,
I have a form that is supposed to accept Japanese text. I set
enctype="utf-8" but my ActionForm is not getting any of these Japanese.
I'm not sure if this is a problem of WebLogic that is not parsing the
request stream with the right encoding or is it that I have to implement my
own multipart request handler with the encoding set to utf-8.
Thanks in advance,
juan
*****************************************************************************
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorized.
If you are not the intended recipient, any disclosure, copying, distribution
or any action taken or omitted to be taken in reliance on it, is prohibited
and may be unlawful. When addressed to our clients any opinions or advice
contained in this email are subject to the terms and conditions expressed in
the governing KPMG client engagement letter.
*****************************************************************************