Hi,
In response to comment of Mr. Fabian Dsouza
http://middlewaremagic.com/weblogic/?page_id=2594#comment-2990
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"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
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"> <jsp-descriptor> <compress-html-template>true</compress-html-template> </jsp-descriptor> </weblogic-web-app>
Step5). Write a Jsp “index.jsp” with full of spaces and Line breaks like following:
<html> <head><title>TestApp</title></head> <body bgcolor=maroon text=white> <center><h2>TestSpaces</h2> Hello There are many Spaces And New Lines In This Page Do u see it? </center> </body> </html>
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.
.
.
Thanks
Jay SenSharma