• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using Jetty GZip Filter

 
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic