Вот мой фильтр:
package webapp.servlet;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class EncodingFilter implements Filter
{
public static final String ENCODING = "UTF-8";
private FilterConfig filterConfig;
public void init(FilterConfig filterConfig) throws ServletException
{
this.filterConfig = filterConfig;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
if(request.getCharacterEncoding() == null)
request.setCharacterEncoding(ENCODING);
chain.doFilter(request, response);
}
public void destroy()
{
}
}
Скомпилировать в WEB-INF/classes и в WEB-INF/web.xml прописать
<filter>
<filter-name>Encoding Filter</filter-name>
<filter-class>webapp.servlet.EncodingFilter</filter-class>
</filter>
и
<filter-mapping>
<filter-name>Encoding Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Лицензия - public domain :)