The Filter worked -- now it works well with the POST as well as the GET. David thank you so much...
Here is the filter.. nice and simple.. Maybe somebody else may need this code one day... But you know, from a Philosophical Perspective, I should not have to create extra code, to get around these incompatibilities in Tomcat. I don't have to do this in Jetty... Regards, Alex. package test.inter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; public class UTF8Filter implements Filter { public void destroy() { // TODO Auto-generated method stub } public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { arg0.setCharacterEncoding("UTF-8"); arg2.doFilter(arg0,arg1); } public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub } } //////////////////////////////// in web.xml <filter> <filter-name>UTF8Filter</filter-name> <filter-class>test.inter.UTF8Filter</filter-class> </filter> <filter-mapping> <filter-name>UTF8Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> On Jan 10, 2008 2:12 PM, David Delbecq <[EMAIL PROTECTED]> wrote: > As you might infer, URIEncoding="UTF-8" only work on the Uri part, and > thus affect only GET. The post is decoded using the browser provided > "content-encoding". Most borwser don't bother to set that header. > Behaviour of tomcat is to then use some default (ISO-8859-1). Best way > to ensure tomcat will use UTF-8 for post decoding is to force it using > request.setCharacterEncoding("UTF-8"), before any call to > getParameter(s). a filter or a valve might be a good place :) > > btw, be carefull, struts (i see you use struts) tends to also have his > default behaviour when decoding POST :) > > > > Aleksandar Matijaca a écrit : > > Hi there, > > > > I am having some issue with submitting foreign language fonts in HTML > form > > to Tomcat. > > If I set up the FORM with method="GET" everything works just fine. > However, > > when I use > > POST, things don't work - I get garbled characters in my servlet from > the > > FORM. > > In the example below, I am showing the headers for both > > GET and POST - the character being sent is a single lower case letter > "f" in > > cyrillic. > > > > > > ************************************************ > > > > The POST method does not work - gives garbled characters - please note > that > > the mytext is PROPERLY ENCODED IN BOTH methods - GET and POST, > > so I don't think that it is a browser issue (i think that my HTML is ok > > too). > > > > > > http://localhost:8080/Inter/takeText.do > > > > POST /Inter/takeText.do HTTP/1.1 > > Host: localhost:8080 > > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) > > Gecko/20071127 Firefox/2.0.0.11 > > Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9 > > ,text/plain;q=0.8,image/png,*/*;q=0.5 > > Accept-Language: en-us,en;q=0.8,sr;q=0.5,hi;q=0.3 > > Accept-Encoding: gzip,deflate > > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 > > Keep-Alive: 300 > > Connection: keep-alive > > Referer: http://localhost:8080/Inter/takeText.do > > Cookie: JSESSIONID=yhhvgybm2jfa; sensitivity=1000.0; > > JSESSIONID=AF8D24C63CE9C16D5DF78E5CDDE26146 > > Content-Type: application/x-www-form-urlencoded > > Content-Length: 13 > > mytext=%D1%84 > > > > > > ******************************************************************** > > > > This is the request using GET - this works just fine - the servlet gets > > mytext nicely decoded... > > > > > > http://localhost:8080/Inter/takeText.do?mytext=%D1%84 > > > > GET /Inter/takeText.do?mytext=%D1%84 HTTP/1.1 > > Host: localhost:8080 > > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) > > Gecko/20071127 Firefox/2.0.0.11 > > Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9 > > ,text/plain;q=0.8,image/png,*/*;q=0.5 > > Accept-Language: en-us,en;q=0.8,sr;q=0.5,hi;q=0.3 > > Accept-Encoding: gzip,deflate > > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 > > Keep-Alive: 300 > > Connection: keep-alive > > Referer: http://localhost:8080/Inter/takeText.do?mytext=%D1%84 > > Cookie: JSESSIONID=yhhvgybm2jfa; sensitivity=1000.0; > > JSESSIONID=AF8D24C63CE9C16D5DF78E5CDDE26146 > > > > > > > > *********************************************** > > My HTML (rendered from the JSP) > > > > > > <html> > > <head> > > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > /> > > > > </head> > > <body> > > <form name="InputLanguageForm" method="POST" > > action="/Inter/takeText.do" accept-charset="UTF-8" > > > <input type="text" name="mytext" value=""> > > <input type="submit" value="Do it"> > > </form> > > </body> > > </html> > > > > ************************************************ > > > > This is the configuration of the Tomcat Connector - if I REMOVE > URIEncoding, > > both GET and POST don't work any more. > > > > <Connector port="8080" protocol="HTTP/1.1" > > connectionTimeout="20000" URIEncoding="UTF-8" > > redirectPort="8443" /> > > > > ************************************************ > > > > > > Thanks for any insight you can give me here... I really don't want to > > change ALL my forms to GET - there should be > > an easier (and more natural) fix for this. > > > > Thanks, Alex. > > > > > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >