| Author |
Using Jetty GZip Filter
|
trupti nigam
Ranch Hand
Joined: Jun 21, 2001
Posts: 602
|
|
Hello,
I am using jetty server to run my application. And my application creates a zip file and send it to end user. I want to use Jetty gzip filer to compress the data that goes over wire.
I added below in the jetty web.xml file to enable the compression.
<filter>
<filter-name>GzipFilter</filter-name>
<!--<filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class> --><!-- for Jetty 7-->
<filter-class>org.mortbay.servlet.GzipFilter</filter-class> <!-- for Jetty 6-->
<init-param>
<param-name>mimeTypes</param-name>
<param-value>text/html,text/plain,text/xml,application/xhtml+xml,text/css,application/javascript,image/svg+xml,text/zip,text/gzip</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
The file getting created by my app is xyz.zip file. How do I know that jetty compression is enabled? Or do I need to do anything else apart from config changes?
Thanks
Trupti
|
 |
trupti nigam
Ranch Hand
Joined: Jun 21, 2001
Posts: 602
|
|
Hi ALL,
I found the answer to my question.It's pretty simple.
The Jetty compression is pretty powerful and can be used to send the large data to the end client in compressed format so that less bandwidth is utilized "over the wire", but at a cost of memory and CPU cycles.
In order to use the Gzip Filter provided by Jetty server add below configuration in web.xml
<filter>
<filter-name>GzipFilter</filter-name>
<!--<filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class> --><!-- for Jetty 7-->
<filter-class>org.mortbay.servlet.GzipFilter</filter-class> <!-- for Jetty 6-->
<init-param>
<param-name>mimeTypes</param-name>
<param-value>text/html,text/plain,text/xml,application/xhtml+xml,text/css,appli cation/javascript,image/svg+xml,application/zip,application/gzip</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
In order to test that the compression is being applied over the wire you can use the "Developer Tools" provided by Chrome or the "FireBug" in fireFox .
For more info please use below link.
http://blog.porotype.com/post/16575655597/compressing-all-the-vaadin-things
Thanks
Trupti
|
 |
 |
|
|
subject: Using Jetty GZip Filter
|
|
|