• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpRequest returns Corrupt Data  RSS feed

 
Udit Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a page where the User can enter Japanese (or multi-lingual) data in a Textbox and submit the form. On Form submission, I am calling a Servlet which retrieves the Data from the request. Here,I am getting mangled/corrupt data.
I gather that most of the web containers interpret the non-ascii/ japanese characters using the default encoding (ISO_8859_1), which produces the junk data at the retrieval time.

Approaches tried:
-- Set the Meta tag with : Content-type: application/x-www-form-urlencoded; charset=UTF-8

-- Tried using various Japanese related charset encodings (SHIFT_JIS, EUC-JP etc) instead of UTF-8

-- In the Servlet, I retrieve the Data as:
String jap = request.getParameter("textBoxName");
String convertedJap = new String(jap.getBytes(), "SJIS"); // convert 8859_1 to sjis

Surprisingly, none of the mentioned approaches seem to work. Could anyone please tell me, how the non-english entered in the Form can be retrieved without corruption ?
Would appreciate any input provided. Thanks in advance !
Cheers, Udit
 
Udit Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

The Following worked :

String in = request.getParameter("TextBoxName");
in = new String(in.getBytes("ISO8859_1"),"utf-8");

Thanks and Regards,
Udit
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Duplicate of:
http://www.coderanch.com/t/360764/Servlets/java/HttpRequest-returning-corrupt-Form-Data

Udit,
Please don't ask the same question in multiple forums.
This practice is called "cross-posting" and is considered extremely rude.
It wastes the time of the people who are trying to help you.
[ July 11, 2005: Message edited by: Ben Souther ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!