Re: [solved] PWC4011: Unable to set request character encoding to UTF-8 from context

Splash Forums PrettyFaces Users [solved] PWC4011: Unable to set request character encoding to UTF-8 from context Re: [solved] PWC4011: Unable to set request character encoding to UTF-8 from context

#21403

m1m
Participant

Here’s full code:

@WebFilter(urlPatterns = "/*")
public class CharacterEncodingFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) {
}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
try {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);
} catch (Exception e) {
Logger.getAnonymousLogger().log(Level.WARNING, Thread.currentThread().getStackTrace()[1].getMethodName(), e);
}
}

@Override
public void destroy() {
}
}