Content-type empty gives IE10 error

Hi ,
I’m migrating from 6.8.12 to 7.1.4. and i’m facing a problem with IE 10, IE10 in IE9 mode - but ok in FF and IE <= 8. The reindeer theme is not applied. In the dev tools of IE there is an error saying SEC7113 and the CSS is ignored due to incompatibility of the mime type for the style.css and later others messages says:

INFO: Assuming CSS loading is not complete, postponing render phase. (.v-loading-indicator height == 0)

SEVERE: CSS files may have not loaded properly.

On 6.8.12 the content-type text/css was sent but not in 7.1.4. The content-type is also empty for the js files

Any help is welcome - thx

At this moment i can’t say what is the source of the problem. The VaadinServlet or my embedded Tomcat (7.0.42). So i won’t open a ticket. But i can give a dirty workaround. Create a servlet filter on /* of your context that will force the content-type. Here is the source:


import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class RessourcesFilter implements Filter {

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#destroy()
	 */
	@Override
	public void destroy() {
		//
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
	 * javax.servlet.ServletResponse, javax.servlet.FilterChain)
	 */
	@Override
	public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {

		String uri = ((HttpServletRequest) arg0).getRequestURI();

		if (uri.endsWith(".css")) {
			arg1.setContentType("text/css");
		} else if (uri.endsWith(".js")) {
			arg1.setContentType("text/javascript");
		} else if (uri.endsWith(".html")) {
			arg1.setContentType("text/html");
		} else if (uri.endsWith(".png")) {
			arg1.setContentType("image/png");
		} else if (uri.endsWith(".gif")) {
			arg1.setContentType("image/gif");
		} else if (uri.endsWith(".jpg")) {
			arg1.setContentType("image/jpg");
		}
		arg2.doFilter(arg0, arg1);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
	 */
	@Override
	public void init(FilterConfig arg0) throws ServletException {
		//
	}
}

Now it works on IE10 in all modes

Hope it helps