I am serving some static HTML files and a servlet all in a single war file from a standalone Tomcat 7.0.35 server using the HTTP Connector.
I want to specify the charset of all the static HTML files by setting the HTTP response header Content-Type=text/html;charset=UTF-8.
Tomcat by default serves HTML files with Content-Type=text/html (no charset portion).
I followed the instructions at:
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8
But the header still contains Content-Type=text/html without the ;charset=UTF-8
My web.xml is reproduced below. Note that I tried changing the url-pattern to /*, *, /index.html, and index.html, but none of these worked.
FYI, the /index.html file is being correctly served by Tomcat (except for the missing ;charset=UTF-8). The /getData servlet is also working correctly, and I have successfully set the servlet's responses Content-Type=text/html;charset=UTF-8 by using response.setContentType("application/json;charset=UTF-8");.
Thanks for any help.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<filter>
<filter-name>CharacterEncoding</filter-name>
<filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>