Jay SenSharma

Jay SenSharma

In response to comment of Mr. Fabian Dsouza


Many times developers write JSP pages which has many spaces inside it.  Like unnecessary Line Breaks, Unnecessary spaces etc. That is required from Developers point of view. Because these spaces and line breaks helps the developers to easily maintain the code and it improves the readability as well.

But it creates problem when it comes to production. These lines and extra spaces degrades the performance of over all n/w transmission because these extra lines and spaces also goes as part of the Response to the client and client can see these spaces in his browser by right clicking on the page    “View Page Source”

WebLogic provides a best way to compress the JSP’s to remove these kind of spaces and line breaks from the JSP if we use “<compress-html-template>true</compress-html-template>”

(Tested on WLS10.3)

Step1). Develop a Web Application directory like following:   “C:TestApp”

Step2). Now create a “WEB-INF” directory inside “C:TestApp”

Step3). Provide the following kind of “web.xml” file inside “C:TestAppWEB-INF”

<?xml version='1.0' encoding='UTF-8'?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Step4). Now Write the “weblogic.xml” file inside “C:TestAppWEB-INF”

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">

Step5). Write a Jsp  “index.jsp”  with full of spaces and Line breaks like following:

<body bgcolor=maroon text=white>


There are many Spaces


New Lines In This Page                                 Do u see it?


Step6). Deploy the “TestApp” in weblogic Server. For quick testing place the “TestApp” web application inside the “<DOMAIN_ROOT>autodeploy”  directory so that for testing we can quickly edit the application as well.

Step7). Now access the WebApplication like following:    http://localhost:7001/TestApp



Step8). Now see the Page Source by right clicking on the page and chose “View Page Source”  like following:



Step9). Now Undeploy the application (just  remove the TestApp from autodeploy directory ) and then remove the “weblogic.xml” file  then again deploy the TestApp to WebLogic then again check the Page Source …You will see all the Spaces and new Lines in it.

View_Page_Source_With Space

View_Page_Source_With Space




Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.