2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

How to compress html containt of JSP file using java?

i want to compress html response from java web application. But not sure how?
userimage
Try as below:

<dependency>
    <groupId>com.googlecode.htmlcompressor</groupId>
    <artifactId>htmlcompressor</artifactId>
    <version>1.4</version>
</dependency>
<dependency>
    <groupId>com.yahoo.platform.yui</groupId>
    <artifactId>yuicompressor</artifactId>
    <version>2.4.6</version>
</dependency>


Use thses dependency or manually download these jar file.

Use below taglib in JSP:

<%@ taglib uri="http://htmlcompressor.googlecode.com/taglib/compressor"
    prefix="compress"%>


<compress:html removeIntertagSpaces="true">
<!DOCTYPE html>
<html lang="en">
// ALL YOUR HTML CODE GOES HERE.
</html>
<compress:html>


You will get compressed HTML in client side.
Answer is