Sherbahadur Khurshid wrote:
> In my case I wanted the bytes comming from the browser to be interpretted
> using the default encoding (I was running on a korean Windows machine so the
> encoding was EUC_KR), however, it seemed like my Web Server (JWS 1.1.3)
> was stubbornly using ISO8859_1 to encode the bytes comming in from the
> browser. So I had to resort to decoding and then re-encoding the bytes in the
> following manner [basically param.getBytes("ISO8859_1") gets me the original
> bytes (i.e. from the browser) and then I use those bytes to create a String -
> the String(bytes) constructor uses the default encoding]:
>
>     public String getParameter(String name)
>     {
>         String param = req.getParameter(name);
>         if(param == null) {return null;}
>
>         try
>         {
>             param = new String(param.getBytes("ISO8859_1"));
>         } catch (UnsupportedEncodingException e) {}
>         return param;
>     }
>
> What Servlet Engine are you using?
> I guess this might be Servlet Engine specific (since ServletRequest is an
> interface).
> Can anyone else on the list shed some light on this?

If the parameters are transmited using the GET method, there is no way
how to specify their encoding, so EVERY servlet engine will treat them
as ISO-8859-1 characters.

If the parameters are transmited using the POST method,
the "Content-type" header should specify their encoding, looking like

Content-type: application/x-www-form-urlencoded; charset=EUC_KR

But AFAIK no current browser sets the "charset" parameter, so
EVERY servlet engine would suppose the default encoding, which is
ISO-8859-1.

Even if a browser sets the "charset" correctly, Apache JServ v1.0
has a bug which treats all requests as they are ISO-8859-1.
I don't know if other servlet engines do it correctly, but anyway,
untill you make POST requests from an applet which sets the "charset",
current browsers don't specify the charset.

I hope now it is clear.

Martin
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   INET, a.s.                          Mgr. Martin Kuba
Kralovopolska 139                  e-mail: [EMAIL PROTECTED]
  601 12 Brno                      WWW: http://www.inet.cz/~makub/
 Czech Republic                    tel: +420-5-41242414/32
--------------------------------------------------------------------

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to