• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpRequest returning corrupt Form 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
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Udit,

I am glad you found your solution, but please do not cross post questions in muliple forums. Thanks.
 
Udit Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was not too sure whether this particular query belonged to JSP or Servlet forum .. I apologise for 'cross-posting' ...
I truly regret the inconvinience caused !
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!