- From: souravm <souravm@infy.com>
- Date: Thu, 21 Feb 2002 09:05:14 +0530
- To: "souravm" <souravm@infy.com>, <www-international@w3.org>
Hi All,
I've a Servlet which runs with a native charset UTF-8. So any form data
coming from a browser client which has encoding type UTF-8 (set through
set content type) works fine.
Now I'm trying to write a client in Java which uses HTTPURLConnection
class to contact the same Servlet. I want to send some data to this
Servlet from the Java client. The data is non-ascii (say Japanese
characters). I'm getting those Japanese strings through args of the
main() method of the client. My client runs in a Windows 2000 machine
and hence I'm assuming the input character set for those strings will be
Shift_JIS. But after I read it in a Java string in my client program, I
assume that it will be converted to Unicode. Later on I'm sending those
strings through HTTPURLConnection to the server after converting it to
UTF-8 through getBytes() method.
The code is something equivalent to shown below -
String strUserId = args[0];
HttpURLConnection urlConn = null;
String strRequestParameters = "userId="+strUserId;
OutputStream oStream = urlConn.getOutputStream();
oStream.write(strRequestParameters.getBytes("UTF-8"));
oStream.flush();
oStream.close();
However, this does not work.
Can anyone please tell me where exactly I'm going wrong ?
Regards,
Sourav
Received on Wednesday, 20 February 2002 22:39:54 UTC