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-encoding>UTF-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="20000" >> 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-name>encodingFilter</filter-name> >> >> <filter-class>path.to.your.filter.SetCharacterEncodingFilter</filter-class> >> <init-param> >> <param-name>encoding</param-name> >> <param-value>UTF-8</param-value> >> </init-param> >> </filter> >> <filter-mapping> >> <filter-name>encodingFilter</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-encoding>UTF-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