Hi,
I'm deploying a JSF WAR onto Tomcat 6.0.14 under Windows 2003 with JVM
version 1.6.0_03-b05, and using MySQL db.
When I submit a form using POST method, and in the server side take the
fields and send them as an email using JavaMail- i lose the UTF-8 encoded
characters sent in the form.
I suspect it's something with the Tomcat configuration because it does not
happen when I deploy to Sun Application Server 8.2
And another thing, UTF-8 characters hardcoded in the sending email method
are sent just fine.
After a week of web search and reading documentation, what I tried so far:
* * Converting from ISO to UTF: *
String subj = "קורות חיים של "+new
String(((String)nameTextField.getValue()).getBytes("ISO-8859-1"), "UTF-8");
message.setSubject(subj, "utf-8");
Also doesn't work with ISO-8859-8 which is for hebrew, what I'm trying to
type..
*
* Inserting URIEncoding="UTF-8" in the HTTP connector in server.xml. *
*
* Making a filter that will change the request encoding to utf-8:
*
The filter class:
public class ReqEncodingFilter implements Filter {
public void destroy() { }
/** Preform the filtering. */
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);
}
public void init(FilterConfig config) throws ServletException { }
}
Also tried with the example encoding filter that comes with Tomcat. The
web.xml part:
<filter>
<filter-name>Set Character Encoding Filter</filter-name>
<filter-class>yarivmt.ReqEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UploadFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Set Character Encoding Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Also tried with <servlet-name>Faces Servlet</servlet-name> instead of the
url-pattern tag.
* * Making a locale-encoding-mapping-list in web.xml: *
<locale-encoding-mapping-list>
<locale-encoding-mapping>
<locale>en</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
<locale-encoding-mapping>
<locale>he</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
<locale-encoding-mapping>
<locale>ru</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
<locale-encoding-mapping>
<locale>iw</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
<locale-encoding-mapping>
<locale>ru_RU</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
</locale-encoding-mapping-list>
Any suggestions where to look highly appreciated!