request.getParameter() values in servlet? Urgent

String str=request.getParameter();

I am facing a problem when i submit the arabic values from hidden form fields using javascript.

In servlet when i tries to retrive the arabic values stored in the session, it displays only

garbage values(ie. ?).

How to solve this problem?

Please clarify and if possible give some samples.

Thanks & Regards,

Govindaraman

[429 byte] By [jgovindaraman] at [2007-9-26 13:38:44]
# 1

Hi Govindaraman,

in O'Reilly's Servlet book in the internationalization section it describes how. You have to change the String returned into bytes using the proper enconding, then back into a String to it will convert to Unicode.

The basics are this:

String parameterName="your param name";

String encoding = "your charset encoding on the page";

String value = request.getParameter(parameterName);

value = new String(value.getBytes(), encoding);

value is now a Unicode string that should be correctly interpreted.

You can use new String( oldString.getBytes(), encoding) to convert between charsets.

chrisb71 at 2007-7-2 14:20:02 > top of Java-index,Desktop,I18N...