dcsimg
How to set character encoding for form data in servlet 2.2 compatible web server
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mehul_Jasani
Posted On:   Monday, July 1, 2002 07:27 PM

I am using apache tomcat 3.x version. I have this problem using servlet 2.2, I am submitting a form containing japanese data in shift jis , using "post" method. When I display it on browser it shows up something like ?e?e?e, I found that it happens because character encoding is required to be set for request object. In servlet 2.2, there is not such thing like setcharacterencoding(), as we have in servlet 2.3. My question is how to solve this problem? i.e., how to set character encoding for post data, so that when I do request.getParameter() it parses the form data based on "shift jis" for japanese data. Regards, Mehul.    More>>


I am using apache tomcat 3.x version. I have this problem using servlet 2.2,


I am submitting a form containing japanese data in shift jis , using "post" method. When I display it on browser it shows up something like ?e?e?e, I found that it happens because character encoding is required to be set for request object.


In servlet 2.2, there is not such thing like setcharacterencoding(), as we have in servlet 2.3.


My question is how to solve this problem? i.e., how to set character encoding for post data, so that when I do request.getParameter() it parses the form data based on "shift jis" for japanese data.


Regards,
Mehul.    <<Less

Re: How to set character encoding for form data in servlet 2.2 compatible web server

Posted By:   Java_Slave  
Posted On:   Tuesday, July 16, 2002 09:18 PM

I read from a articals :
"The setCharacterEncoding() call may throw java.io.UnsupportedEncodingException if the encoding is not supported. This functionality is also available for users of API 2.2 and earlier, as part of the com.oreilly.servlet.ParameterParser class."

URL : http://www.servlets.com/cos/index.html

I don't know it does work or not. But I hope it's useful for you. :)

Re: How to set character encoding for form data in servlet 2.2 compatible web server

Posted By:   Steve_Leung  
Posted On:   Monday, July 8, 2002 07:24 AM

It seems use
String japanEncoding = new String( req.getParameter("Input", "ISO-8859-1"), "Shift-jis" );


I am not sure the correct name for "Shift-jis" is correct or not. Test it yourself.
About | Sitemap | Contact