I have configured a GzipFilter
in my custom WebApplicationInitializer
and when I try to access the website. It shows me,
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression. Please contact the website owners to inform them of this problem.
The GzipFilter I'm using is from this blog,
http://tutorials.jenkov.com/java-servlets/gzip-servlet-filter.html
I can see the browser request gzip content. And for the files that are downloaded I can see the Response header Content-Encoding:gzip
. But, I don't see why I get this error. Below is my app config,
public class WebInitializer implements WebApplicationInitializer{
@Override
public void onStartup(ServletContext container) throws ServletException {
//configuration code
container.addFilter("GzipCompressionFilter",GzipFilter.class).addMappingForUrlPatterns(null, false, "/*");
}
}
If I use the filter from this post,
http://www.oodlestechnologies.com/blogs/Gzip-Servlet-Filter-in-Spring-MVC
The request never ends and the files download partially and loads infinitely. What could be the problem?
I'm using maven-jetty plugin to start jetty with mvn jetty:run
goal. Currently I'm using the above filters to serve GZip content from the server. Is there any other way in maven-jetty plugin to enable GZip compression? GZipFilter is deprecated and I can't see any GZipHandler implementation for embedded jetty server. My maven-jetty config,
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<stopKey>jettyStop</stopKey>
<stopPort>9191</stopPort>
<httpConnector>
<host>0.0.0.0</host>
<port>8080</port>
</httpConnector>
</configuration>
</plugin>