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
___________________________________________________________________________
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