I am looking to improve front-end performance of my application, so I used YSlow tool in Firefox. When I ran this tool for my app, in the YSlow grade tab it showed up a issue \'
I recommend to use a Servlet Filter (since servlet 2.3 spec)
A gzip filter is well documented, so there is no need to reinvent the wheel:
Also, some servlet containers can do gzip on the fly. Take a look at this related question.