-
1. Re: Get parameters from request decoded with utf-8
starksm64 Nov 29, 2004 12:24 PM (in response to mskjeret)Create a bug report with an example of what your doing so we can look into it:
http://jira.jboss.com/jira/browse/JBWEB -
2. Re: Get parameters from request decoded with utf-8
oagady Nov 29, 2004 11:43 PM (in response to mskjeret)try this (for example you want to get the field "message" from the request):
request.setCharacterEncoding("utf-8");
String message = new String(request.getParameter("message").getBytes("ISO-8859-1"),"utf-8");
It works for me. Just setting the character encoding didn't work. I ran this code in jboss 3.0, it worked. Now I run it in 4.0 - works the same way.
Olga -
3. Re: Get parameters from request decoded with utf-8
mskjeret Dec 5, 2004 5:00 PM (in response to mskjeret)I dont think that code will work in any situation, I might be wrong though.
It looks a bit dangerous at least, and a bit hard to apply everywhere.
But I have found a bulletproof solution for this (the only solution I think).
I used to have this working in tomcat 4.
I had a encoding filter applied in front of the servlet, setting the
request.setCharacterEncoding("UTF-8") before anything had accessed the request input stream.
This just stopped working suddenly when upgrading to tomcat 5.0.26.
It seems that they had removed the request.setCharacterEncoding support, and had applied something to the Connector element in server.xml of tomcat.
My Connector now looks like this in conf/server.xml<Connector port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" URIEncoding="UTF-8" disableUploadTimeout="true" />
Look at URIEncoding="UTF-8"..
request.getParameter("word") will now give me the UTF-8 decoded string.
You need then to make sure that each url in <a href is properly encoded.
I think form submit will be correctly encoded in utf-8 if the meta tag says the page is in utf-8, at least that is what I see in firefox and IE.
Thanks
Magne -
4. Re: Get parameters from request decoded with utf-8
germuska Sep 8, 2005 6:58 PM (in response to mskjeret)"mskjeret" wrote:
My Connector now looks like this in conf/server.xml<Connector port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" URIEncoding="UTF-8" disableUploadTimeout="true" />
Look at URIEncoding="UTF-8"..
A solution which sets the URIEncoding value for the Tomcat connector will only apply to GET parameters. (I don't know if the "Get" in the original message subject was referring to the HTTP request method, but I assumed it was more like "retrieve") POST parameters are sent with the encoding explicitly marked as part of the content-type, conventionally according to the encoding of the page in which the form was presented.
Our attempt to implement a ServletFilter calling setRequestEncoding does not seem to be invoked when run under JBoss 3.2.5, although the same exact web application deployed to a standalone Tomcat 5.0.25 server works correctly.
If anyone has similar experience, please advise.