Hi Sanjay,
1. As far as I know all Java Virtual Machines support ISO8859_1 (including the
JRE)
see: http://java.sun.com/products/jdk/1.1/docs/guide/intl/encoding.doc.html
2. hmmm.... that's strange. I ran into a problem with the getParameter method
(of the request object) as well but it was exactly the opposite of what you're
describing.
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?
Thanks,
-Sher
/************* ORIGINAL MESSAGE ********************/
Date: Thu, 6 Jan 2000 12:00:37 +0530
From: Sanjay <[EMAIL PROTECTED]>
Subject: Retreiving Encoded data from servlets
Hi,
My problem involves Internationalization. I have a servlet that gets =
request data from applets. The applets could be run from any machine =
(win32, unix, linux....whatever). I always encrypt my data before i send =
it from the applet, resulting in some characters being mapped between =
\u0080 to \u009F. These characters are valid in ISO8859_n
Encoding scheme, but become '?' when used from winNT machine (since the =
encoding default there is Cp1252). So i'm always setting the Encoding of =
any data (POSTed from the applet, thru a OutputStreamWriter) to 8859_1. =
I have two doubts wrt the above:
1. Can there be a case when the stmt:=20
OutputStreamWriter out =3D new OutputStreamWriter(someOutputStream, =
"8859_1");
gives me UnsupportedEncodingException on any machine ? (in other words, =
is 8859_1 supported on ALL machines ?)
2. I get the data into the Servlet using getParameter("name"). This =
returns me a string with the system's (web server's) default encoding =
scheme. In the case my web server is on NT, i again get a problem of =
chars between \u0080 and \u009F being translated to '?'. I even tried =
System.setProperty("file.encoding", "8859_1") but to no avail. The =
problem still persists. Is there some way i can see light ?
Thanx a lot in advance...
Sanjay
___________________________________________________________________________
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