A filter implements htmlcompressor.
Javascript, CSS Compress: YUI Compressor
web.xml
<filter>
<filter-name>HtmlCompressorFilter</filter-name>
<filter-class>org.cweili.htmlcompressor.HtmlCompressorFilter</filter-class>
<init-param>
<param-name>compressJavaScript</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>compressCss</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>HtmlCompressorFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>