RE: struts.i18n.encoding
Use following in JSP page. You should get with all default properties. By default in tomcat it is ISO-8859-1 %@ page pageEncoding=UTF-8 contentType=text/html; charset=UTF-8 % In worst case test some thing like this in your action file. String strTemp=new String(strProperty.getBytes(ISO-8859-1), UTF-8); -Original Message- From: carl ballantyne [mailto:carl.ballant...@cast-info.es] Sent: Friday, November 20, 2009 4:22 PM To: user@struts.apache.org Subject: Re: struts.i18n.encoding Hi Cristian, Thanks very much for your response. I am using GlassFish 2.1 so will have a look to see if I can implement your type of solution. What I don't get is why we need to apply a filter when already the server is configured to use UTF-8 and we have UTF-8 defined in the meta for the JSP. It just seems strange that nobody has got this to work with struts.i18.encoding. Surely there must be some other people out there with multi language struts 2 apps. I will try your solution and keep digging some more. Cheers, Carl. Quoting Cristian Peraferrer corellia...@gmail.com: In my application also used the 'struts.i18.encoding=UTF-8' but I had the same problem. But I found a way to get it to work. This way you are only telling struts that has to use UTF-8. But you also need to tell to your Applications Container (Tomcat for example) that you want UTF-8. 1. Set the URI encoding of Tomcat's server.xml configuration file. Set URIEncoding=UTF-8 in your http/https connectors: !-- Define a non-SSL HTTP/1.1 Connector on port 80 -- Connector URIEncoding=UTF-8 acceptCount=100 connectionTimeout=2 disableUploadTimeout=true enableLookups=false maxHttpHeaderSize=8192 maxSpareThreads=75 maxThreads=150 minSpareThreads=25 port=80 redirectPort=443/ 2. Set a custom filter to configure POST requests use UTF-8: !-- To get POST requests as UTF-8 -- filter filter-nameencodingFilter/filter-name filter-classpath.to.your.filter.SetCharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameencodingFilter/filter-name url-pattern/*/url-pattern /filter-mapping Tomcat already comes with such an example filter of SetCharacterEncodingFilter. 3. Also in my application's web.xml I have set that JSPs use UTF-8 as a default: jsp-config !-- UTF-8 as the default JSP encoding -- jsp-property-group url-pattern*.jsp/url-pattern page-encodingUTF-8/page-encoding /jsp-property-group /jsp-config 4. In every JSP you I have the following typical meta tag inside head: meta http-equiv=Content-Type content=text/html; charset=UTF-8 / I hope it will help. Cristian. On Fri, Nov 20, 2009 at 10:14 AM, carl ballantyne carl.ballant...@cast-info.es wrote: Hi Guys, I have an app with form fields and when submitting them to my Struts 2 actions the values are getting garbled. For example españa becomes espa?. I think the problem is with Struts because when I create a basic jsp page and submit back to itself and display the form field - it works fine. I have tried setting struts.i18n.encoding=UTF-8 in the struts.properties file and the struts.xml file to no avail. Has anyone used this with success? I have searched the forums and it seems to me that people have to resort to custom filters to workaround the problem. Cheers, Carl. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- GPG Key-ID: 0x564903FA - JID: corell...@swissjabber.ch - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: struts.i18n.encoding
Thanks but I actually found the solution (for GlassFish 2.1) and posted a reply to the list a few days back now. Just search the archive and you should see it. Cheers for the suggestion though. Quoting Raghuveer.V raghuve...@infotechsw.com: Use following in JSP page. You should get with all default properties. By default in tomcat it is ISO-8859-1 %@ page pageEncoding=UTF-8 contentType=text/html; charset=UTF-8 % In worst case test some thing like this in your action file. String strTemp=new String(strProperty.getBytes(ISO-8859-1), UTF-8); -Original Message- From: carl ballantyne [mailto:carl.ballant...@cast-info.es] Sent: Friday, November 20, 2009 4:22 PM To: user@struts.apache.org Subject: Re: struts.i18n.encoding Hi Cristian, Thanks very much for your response. I am using GlassFish 2.1 so will have a look to see if I can implement your type of solution. What I don't get is why we need to apply a filter when already the server is configured to use UTF-8 and we have UTF-8 defined in the meta for the JSP. It just seems strange that nobody has got this to work with struts.i18.encoding. Surely there must be some other people out there with multi language struts 2 apps. I will try your solution and keep digging some more. Cheers, Carl. Quoting Cristian Peraferrer corellia...@gmail.com: In my application also used the 'struts.i18.encoding=UTF-8' but I had the same problem. But I found a way to get it to work. This way you are only telling struts that has to use UTF-8. But you also need to tell to your Applications Container (Tomcat for example) that you want UTF-8. 1. Set the URI encoding of Tomcat's server.xml configuration file. Set URIEncoding=UTF-8 in your http/https connectors: !-- Define a non-SSL HTTP/1.1 Connector on port 80 -- Connector URIEncoding=UTF-8 acceptCount=100 connectionTimeout=2 disableUploadTimeout=true enableLookups=false maxHttpHeaderSize=8192 maxSpareThreads=75 maxThreads=150 minSpareThreads=25 port=80 redirectPort=443/ 2. Set a custom filter to configure POST requests use UTF-8: !-- To get POST requests as UTF-8 -- filter filter-nameencodingFilter/filter-name filter-classpath.to.your.filter.SetCharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameencodingFilter/filter-name url-pattern/*/url-pattern /filter-mapping Tomcat already comes with such an example filter of SetCharacterEncodingFilter. 3. Also in my application's web.xml I have set that JSPs use UTF-8 as a default: jsp-config !-- UTF-8 as the default JSP encoding -- jsp-property-group url-pattern*.jsp/url-pattern page-encodingUTF-8/page-encoding /jsp-property-group /jsp-config 4. In every JSP you I have the following typical meta tag inside head: meta http-equiv=Content-Type content=text/html; charset=UTF-8 / I hope it will help. Cristian. On Fri, Nov 20, 2009 at 10:14 AM, carl ballantyne carl.ballant...@cast-info.es wrote: Hi Guys, I have an app with form fields and when submitting them to my Struts 2 actions the values are getting garbled. For example españa becomes espa?. I think the problem is with Struts because when I create a basic jsp page and submit back to itself and display the form field - it works fine. I have tried setting struts.i18n.encoding=UTF-8 in the struts.properties file and the struts.xml file to no avail. Has anyone used this with success? I have searched the forums and it seems to me that people have to resort to custom filters to workaround the problem. Cheers, Carl. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- GPG Key-ID: 0x564903FA - JID: corell...@swissjabber.ch - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts.i18n.encoding
I ended up figuring out the real problem in the end. (Hope this helps anyone faced with the same situation) Firstly I was blaming Struts2 when it was actually innocent. When I created the test JSP I did not see that Eclipse had added automatically the tag %@ page language=java contentType=text/html; charset=UTF-8 pageEncoding=UTF-8% which of course meant the request would be UTF-8 encoded. I also created an interceptor in Struts2 and was able to see the request variables and they were not being encoded correctly. So the problem was with GlassFish 2.1. It was then just a matter of following Cristian's steps and adapting them for GlassFish. 1) Set encoding of requests to GlassFish 2.1 by adding the following to your sub-web.xml file. No need for a filter. sun-web-app locale-charset-info default-locale= locale-charset-map locale= charset=/ parameter-encoding default-charset=UTF-8/ /locale-charset-info /sun-web-app 2) In web.xml put the following (or else you need to put %@ page pageEncoding=UTF-8 % at the top of every single JSP in your app) jsp-config !-- UTF-8 as the default JSP encoding -- jsp-property-group url-pattern*.jsp/url-pattern page-encodingUTF-8/page-encoding /jsp-property-group /jsp-config 3) In every JSP you I have the following typical meta tag inside head: meta http-equiv=Content-Type content=text/html; charset=UTF-8 / Cheers, Carl. Quoting Cristian Peraferrer corellia...@gmail.com: In my application also used the 'struts.i18.encoding=UTF-8' but I had the same problem. But I found a way to get it to work. This way you are only telling struts that has to use UTF-8. But you also need to tell to your Applications Container (Tomcat for example) that you want UTF-8. 1. Set the URI encoding of Tomcat's server.xml configuration file. Set URIEncoding=UTF-8 in your http/https connectors: !-- Define a non-SSL HTTP/1.1 Connector on port 80 -- Connector URIEncoding=UTF-8 acceptCount=100 connectionTimeout=2 disableUploadTimeout=true enableLookups=false maxHttpHeaderSize=8192 maxSpareThreads=75 maxThreads=150 minSpareThreads=25 port=80 redirectPort=443/ 2. Set a custom filter to configure POST requests use UTF-8: !-- To get POST requests as UTF-8 -- filter filter-nameencodingFilter/filter-name filter-classpath.to.your.filter.SetCharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameencodingFilter/filter-name url-pattern/*/url-pattern /filter-mapping Tomcat already comes with such an example filter of SetCharacterEncodingFilter. 3. Also in my application's web.xml I have set that JSPs use UTF-8 as a default: jsp-config !-- UTF-8 as the default JSP encoding -- jsp-property-group url-pattern*.jsp/url-pattern page-encodingUTF-8/page-encoding /jsp-property-group /jsp-config 4. In every JSP you I have the following typical meta tag inside head: meta http-equiv=Content-Type content=text/html; charset=UTF-8 / I hope it will help. Cristian. On Fri, Nov 20, 2009 at 10:14 AM, carl ballantyne carl.ballant...@cast-info.es wrote: Hi Guys, I have an app with form fields and when submitting them to my Struts 2 actions the values are getting garbled. For example españa becomes espa?. I think the problem is with Struts because when I create a basic jsp page and submit back to itself and display the form field - it works fine. I have tried setting struts.i18n.encoding=UTF-8 in the struts.properties file and the struts.xml file to no avail. Has anyone used this with success? I have searched the forums and it seems to me that people have to resort to custom filters to workaround the problem. Cheers, Carl. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- GPG Key-ID: 0x564903FA - JID: corell...@swissjabber.ch - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts.i18n.encoding
I'm glad you found your solution :) On Mon, Nov 23, 2009 at 1:38 PM, carl ballantyne carl.ballant...@cast-info.es wrote: I ended up figuring out the real problem in the end. (Hope this helps anyone faced with the same situation) Firstly I was blaming Struts2 when it was actually innocent. When I created the test JSP I did not see that Eclipse had added automatically the tag %@ page language=java contentType=text/html; charset=UTF-8 pageEncoding=UTF-8% which of course meant the request would be UTF-8 encoded. I also created an interceptor in Struts2 and was able to see the request variables and they were not being encoded correctly. So the problem was with GlassFish 2.1. It was then just a matter of following Cristian's steps and adapting them for GlassFish. 1) Set encoding of requests to GlassFish 2.1 by adding the following to your sub-web.xml file. No need for a filter. sun-web-app locale-charset-info default-locale= locale-charset-map locale= charset=/ parameter-encoding default-charset=UTF-8/ /locale-charset-info /sun-web-app 2) In web.xml put the following (or else you need to put %@ page pageEncoding=UTF-8 % at the top of every single JSP in your app) jsp-config !-- UTF-8 as the default JSP encoding -- jsp-property-group url-pattern*.jsp/url-pattern page-encodingUTF-8/page-encoding /jsp-property-group /jsp-config 3) In every JSP you I have the following typical meta tag inside head: meta http-equiv=Content-Type content=text/html; charset=UTF-8 / Cheers, Carl. Quoting Cristian Peraferrer corellia...@gmail.com: In my application also used the 'struts.i18.encoding=UTF-8' but I had the same problem. But I found a way to get it to work. This way you are only telling struts that has to use UTF-8. But you also need to tell to your Applications Container (Tomcat for example) that you want UTF-8. 1. Set the URI encoding of Tomcat's server.xml configuration file. Set URIEncoding=UTF-8 in your http/https connectors: !-- Define a non-SSL HTTP/1.1 Connector on port 80 -- Connector URIEncoding=UTF-8 acceptCount=100 connectionTimeout=2 disableUploadTimeout=true enableLookups=false maxHttpHeaderSize=8192 maxSpareThreads=75 maxThreads=150 minSpareThreads=25 port=80 redirectPort=443/ 2. Set a custom filter to configure POST requests use UTF-8: !-- To get POST requests as UTF-8 -- filter filter-nameencodingFilter/filter-name filter-classpath.to.your.filter.SetCharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameencodingFilter/filter-name url-pattern/*/url-pattern /filter-mapping Tomcat already comes with such an example filter of SetCharacterEncodingFilter. 3. Also in my application's web.xml I have set that JSPs use UTF-8 as a default: jsp-config !-- UTF-8 as the default JSP encoding -- jsp-property-group url-pattern*.jsp/url-pattern page-encodingUTF-8/page-encoding /jsp-property-group /jsp-config 4. In every JSP you I have the following typical meta tag inside head: meta http-equiv=Content-Type content=text/html; charset=UTF-8 / I hope it will help. Cristian. On Fri, Nov 20, 2009 at 10:14 AM, carl ballantyne carl.ballant...@cast-info.es wrote: Hi Guys, I have an app with form fields and when submitting them to my Struts 2 actions the values are getting garbled. For example españa becomes espa?. I think the problem is with Struts because when I create a basic jsp page and submit back to itself and display the form field - it works fine. I have tried setting struts.i18n.encoding=UTF-8 in the struts.properties file and the struts.xml file to no avail. Has anyone used this with success? I have searched the forums and it seems to me that people have to resort to custom filters to workaround the problem. Cheers, Carl. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- GPG Key-ID: 0x564903FA - JID: corell...@swissjabber.ch - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Saeed Iqbal CEO http://www.iqbalconsulting.com Struts - J2EE - Application Architects and Developers
struts.i18n.encoding
Hi Guys, I have an app with form fields and when submitting them to my Struts 2 actions the values are getting garbled. For example españa becomes espa?. I think the problem is with Struts because when I create a basic jsp page and submit back to itself and display the form field - it works fine. I have tried setting struts.i18n.encoding=UTF-8 in the struts.properties file and the struts.xml file to no avail. Has anyone used this with success? I have searched the forums and it seems to me that people have to resort to custom filters to workaround the problem. Cheers, Carl. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts.i18n.encoding
In my application also used the 'struts.i18.encoding=UTF-8' but I had the same problem. But I found a way to get it to work. This way you are only telling struts that has to use UTF-8. But you also need to tell to your Applications Container (Tomcat for example) that you want UTF-8. 1. Set the URI encoding of Tomcat's server.xml configuration file. Set URIEncoding=UTF-8 in your http/https connectors: !-- Define a non-SSL HTTP/1.1 Connector on port 80 -- Connector URIEncoding=UTF-8 acceptCount=100 connectionTimeout=2 disableUploadTimeout=true enableLookups=false maxHttpHeaderSize=8192 maxSpareThreads=75 maxThreads=150 minSpareThreads=25 port=80 redirectPort=443/ 2. Set a custom filter to configure POST requests use UTF-8: !-- To get POST requests as UTF-8 -- filter filter-nameencodingFilter/filter-name filter-classpath.to.your.filter.SetCharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameencodingFilter/filter-name url-pattern/*/url-pattern /filter-mapping Tomcat already comes with such an example filter of SetCharacterEncodingFilter. 3. Also in my application's web.xml I have set that JSPs use UTF-8 as a default: jsp-config !-- UTF-8 as the default JSP encoding -- jsp-property-group url-pattern*.jsp/url-pattern page-encodingUTF-8/page-encoding /jsp-property-group /jsp-config 4. In every JSP you I have the following typical meta tag inside head: meta http-equiv=Content-Type content=text/html; charset=UTF-8 / I hope it will help. Cristian. On Fri, Nov 20, 2009 at 10:14 AM, carl ballantyne carl.ballant...@cast-info.es wrote: Hi Guys, I have an app with form fields and when submitting them to my Struts 2 actions the values are getting garbled. For example españa becomes espa?. I think the problem is with Struts because when I create a basic jsp page and submit back to itself and display the form field - it works fine. I have tried setting struts.i18n.encoding=UTF-8 in the struts.properties file and the struts.xml file to no avail. Has anyone used this with success? I have searched the forums and it seems to me that people have to resort to custom filters to workaround the problem. Cheers, Carl. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- GPG Key-ID: 0x564903FA - JID: corell...@swissjabber.ch - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts.i18n.encoding
Hi Cristian, Thanks very much for your response. I am using GlassFish 2.1 so will have a look to see if I can implement your type of solution. What I don't get is why we need to apply a filter when already the server is configured to use UTF-8 and we have UTF-8 defined in the meta for the JSP. It just seems strange that nobody has got this to work with struts.i18.encoding. Surely there must be some other people out there with multi language struts 2 apps. I will try your solution and keep digging some more. Cheers, Carl. Quoting Cristian Peraferrer corellia...@gmail.com: In my application also used the 'struts.i18.encoding=UTF-8' but I had the same problem. But I found a way to get it to work. This way you are only telling struts that has to use UTF-8. But you also need to tell to your Applications Container (Tomcat for example) that you want UTF-8. 1. Set the URI encoding of Tomcat's server.xml configuration file. Set URIEncoding=UTF-8 in your http/https connectors: !-- Define a non-SSL HTTP/1.1 Connector on port 80 -- Connector URIEncoding=UTF-8 acceptCount=100 connectionTimeout=2 disableUploadTimeout=true enableLookups=false maxHttpHeaderSize=8192 maxSpareThreads=75 maxThreads=150 minSpareThreads=25 port=80 redirectPort=443/ 2. Set a custom filter to configure POST requests use UTF-8: !-- To get POST requests as UTF-8 -- filter filter-nameencodingFilter/filter-name filter-classpath.to.your.filter.SetCharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameencodingFilter/filter-name url-pattern/*/url-pattern /filter-mapping Tomcat already comes with such an example filter of SetCharacterEncodingFilter. 3. Also in my application's web.xml I have set that JSPs use UTF-8 as a default: jsp-config !-- UTF-8 as the default JSP encoding -- jsp-property-group url-pattern*.jsp/url-pattern page-encodingUTF-8/page-encoding /jsp-property-group /jsp-config 4. In every JSP you I have the following typical meta tag inside head: meta http-equiv=Content-Type content=text/html; charset=UTF-8 / I hope it will help. Cristian. On Fri, Nov 20, 2009 at 10:14 AM, carl ballantyne carl.ballant...@cast-info.es wrote: Hi Guys, I have an app with form fields and when submitting them to my Struts 2 actions the values are getting garbled. For example españa becomes espa?. I think the problem is with Struts because when I create a basic jsp page and submit back to itself and display the form field - it works fine. I have tried setting struts.i18n.encoding=UTF-8 in the struts.properties file and the struts.xml file to no avail. Has anyone used this with success? I have searched the forums and it seems to me that people have to resort to custom filters to workaround the problem. Cheers, Carl. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- GPG Key-ID: 0x564903FA - JID: corell...@swissjabber.ch - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
struts.i18n.encoding
I want to set other country language character set,I know I should set web.xml with struts.i18n.encoding=... but I don't know the value which struts.i18n.encoding permited,anyone could give me a character list of struts.i18n.encoding? Thanks