Encoding Problem in Java Web Applications..

..only relevant for first POST request?!?!


package biz.tugay;
import javax.servlet.*;
import java.io.IOException;
 * User: Koray Tugay (koray@tugay.biz)
 * Date: 7/28/2016
 * Time: 8:37 PM
public class RequestEncodingFilter implements Filter {
    public void init(FilterConfig filterConfig) throws ServletException {
    public void doFilter(ServletRequest servletRequest,
                         ServletResponse servletResponse,
                         FilterChain filterChain) throws IOException, ServletException {
        final String characterEncoding = servletRequest.getCharacterEncoding();
        if (characterEncoding == null) {
        filterChain.doFilter(servletRequest, servletResponse);
    public void destroy() {
I do not know why this happens, but with the first POST request, getCharacterEncoding returns null and I do not know..

Here are some links: 1, 2 , 3!