Servlet request.getParameters is not English symbolic help!

I desperately need help.

I have a Java Servlet that is accessed by an HTTP Get URL with eight parameters. The problem is that the options are not exclusive to English. Any other language can be in these parameters, for example Hebrew.

Now when I post data - either from the class that is supposed to send the Get request, or just from the browser address bar, the request I see when debugging (Netbeans) has gibberish characters and the parameters themselves, post request.getParameter - ??? ? question marks.

How and where will I solve this?

+2


source to share


2 answers


Your servlet module should have a setting that controls the character encoding used for URL parameters. For each language support, UTF-8 is a great choice, but it is not the default encoding on many servers.

Tomcat uses the ISO-8859-1 standard character decoder for URL parameters, regardless of the encoding of the page containing the URL. This can be changed using the "URIEncoding" attribute in its Connector configuration . Other application servers may have similar settings.



If the server expects UTF-8 encoded parameters, the page that sends them must also be UTF-8 encoded.

This article addresses many of the common problems encountered when working with JSPs.

0


source


I suspect your server is in UTF-8 mode, but your url is Latin-1 encoded. What question marks do you get, "?" or ""? This will shed light on who is performing the transformation.

You need to change your connector to Latin-1 by adding the URIEncoding = "ISO-8859-1" attribute, or you can transcode the url to UTF-8.



If the url is browser encoded, you are closed. There is no solution as it might go anyway depending on browsers. See my question,

Handling character encoding in URIs on Tomcat

0


source







All Articles