<filter>
<filter-name>CharacterEncoding</filter-name>
<filter-class>com.ebay.filter.ResponseHeaderOverride</filter-class>
</filter>
<filter-mapping>
<filter-name>CharacterEncoding</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
With above configurations defined in web.xml, in our customized filter, we only need to write several lines of code in doFilter() method:
res.setContentType("text/html;charset=UTF-8");
filterChain.doFilter(req, res);