Hello all:

I have combined both Martin and Jonathan suggestion as i have weblogic 5.1
with SP9. But still can't get input of chinese to work. when i display the
inputed chinese on the resulting jsp page,  it's not readable.

I am using 'utf-8' all the way(on all jsp pages, input and output). I
followed step 1 & 2 on the jsp page level. For step 3, i added the following
to my web app's web.xml file:
<web-app>
        <!-- configure input charset to be utf-8 -->
        <context-param>
                <param-name>weblogic.httpd.inputCharset./*</param-name>
                <param-value>UTF-8</param-value>
        </context-param>
...
</web-app>

I even followed the weblogic 5.1 sp9 doc and added the following to the
weblogic.properties file:
weblogic.httpd.inputCharset./*=UTF-8

Still no luck on capturing chinese input. I can display chinese fine on the
jsp pages when reading the keyed value from Resource bundle properties
files.

Please help? Am i missing something.
TIA
Simon



-----Original Message-----
From: Martin Cooper [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 25, 2001 6:37 PM
To: [EMAIL PROTECTED]
Subject: Re: Encodings on form submits?


I know this is an old post, but better late than never... :-)

We are doing the following:

1) Specify the content type for the JSP output:

    <%@ page contentType="text/html; charset=utf-8" %>

You can also do this by setting the content type header manually, using
response.setContentType().

2) Specify the content type to the browser:

    <meta http-equiv="content-type" content="text/html; charset=utf-8">

3) Specify the default content type to the container. In our case, we are
using Resin, and so do this:

    <web-app id='/' character-encoding='utf-8' ... >

The first ensures that the JSP page is treated as UTF-8, which can represent
all the characters you need. The second ensures that the browser knows that.
Since the browser uses the encoding of the page to send form data,
submissions will now use UTF-8. The third ensures that the container
interprets all submissions as UTF-8.

Other than figuring it out in the first place :-) we have had no problems
with this. We can correctly display, and interpret input, in any language -
Chinese, Japanese, European languages, etc.

--
Martin Cooper


----- Original Message -----
From: "Ben Flaumenhaft" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 05, 2001 1:40 PM
Subject: Encodings on form submits?


>
> Folks,
>
> I'm struggling with how to handle form submissions with non-Latin
character
> encodings using a Struts action and form beans.
>
> As I understand it, browsers use the character encoding of the form's page
> (hex-encoded) for submitting form parameters. I've seen plenty of code to
> convert request parameters by hand, e.g.
>
>         try
>         {
>             return new String(inParam.getBytes("8859_1"), encoding);
>         }
>         catch (UnsupportedEncodingException e)
>         {
>             return inParam;
>         }
>
> ... but this implies that you know the character encoding. Until Servlet
2.3
> is standard, you can't just say request.setEncoding ().
>
> So: how to do this in Struts? Ultimately, what I need is my form beans to
> have their Strings set properly.
>
> I can think of a few ways.
>
> (1) Let the form bean handle it on set () methods for Strings. Every form
> class could extend a base class with a decodeString (), and every form
class
> could call this method.
>
> I'm not thrilled about this, since it'd be easy to forget and it's a lot
of
> extra coding on every set call.
>
> (2) Modify Struts to do this automatically. This isn't trivial, since the
> calls to populate beans
> are buried pretty deeply in ActionServlet, RequestUtils, and BeanUtils.
>
> In either case, the handler (whether Struts utils or the beans themselves)
> would need to know the encoding to use! The best I can come up with is
that
> every form would embed a hidden parameter "encoding" -- this is how
iPlanet
> handles this, they have a j_encoding parameter on forms which tells the
> handler how to decode params. (I could modify html:form to do this
> automatically, too ...)
>
> Thoughts?
>
> Thanks,
> Ben
>
>

You must configure your web application to DECODE the utf8 encoded stuff.
In weblogic I make this entry in the web.xml file:

<web-app>
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>UTF-8</param-value>
</context-param>
</web-app>

I'm not sure what you need for tomcat configuration

QUOTING AN E-MAIL FROM HANS BERGSTEN
========================================
8859-1 is [currently] the default
encoding of HTTP. When a browser sends a parameter in some encoding, such
as UTF-8, it encodes each character byte value as a hexadecimal string using
the encoding for the page (e.g. UTF-8). At the server, however, the part of
the container that interprets these character values always assumes they
are 8859-1 byte values. So it created a Unicode string based on the byte
values interpreted as 8859-1. In the Servlet 2.3 spec it will be possible to
tell the container to use
another encoding that 8859-1 to interpret the parameter value bytes, but
for now we're stuck with this "hack".



----- Original Message -----
From: "Hartmut Bernecker" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 26, 2001 10:00 AM
Subject: Submitting unicode characters from form fields


> Guten Tag,
>
> my problem is:
> How can unicode be submitted from form fields in an adequate way to the
> server?
>
> I'm using the struts framework and trying to submit some unicode text in
> a HTML form to the server. My Target is, to use that unicode characters
> on the server (as parameter for a RPC to a lecacy application).
>
> It is not a problem for me to display that unicode characters in the
> browser by declaring:
>
>    <%@ page language="java" contentType="text/html;charset=UTF-8" %>
>
>    and in the head:
>
>    <head><meta http-equiv="content-type" content="text/html;
> charset=utf-8"></head>
>
> But it is a problem to go the way in the other direction:
>
> 1. The IE5.5 (much better: Netscape 6) does not display the unicode
> characters in the form field correctly (i. e. he shows something like
> |||||||). BTW: I cut & paste the Unicode from the browser from a page
> that displays unicode characters (s.a.).
>
> 2. When I submit the form, then I ask in the Action-Class for
> request.getCharacterEncoding(), but the resulting String is null, even
> though I specified in my JSP something like:
> <form:form action="direktSuche.do" method="post" target="content"
> enctype="text/plain;charset=UTF-8">. Why is getCharacterEncoding() ==
> null??
>
> 3. When I read the form-field with the unicode data, I get:
> ???. I think, this is UTF-8, isn't it (I'm not sure)?
>
> 4. When I take exactly that string and display it again with a JSP-Page,
> I get somthing other (Ӂƣ??ƱƸƸ) than the original, from where I
> cutted & pasted the characters (s. a.). Why?
>
> Question: Must I convert the POSTed data before processing with it? Must
> I implement some mechanism for converting UTF-8[??] to Unicode?
>
> I greatly appreciate your help!
>
> Chiao
> Hartmut
>



============================================================================
This message is intended only for the use of the Addressee(s) and may
contain information that is PRIVILEGED and CONFIDENTIAL. If you are not
the intended recipient, dissemination of this communication is prohibited.
If you have received this communication in error, please erase all copies
of the message and its attachments and notify [EMAIL PROTECTED]
immediately.
============================================================================

Reply via email to