stripping out extra spaces in JSP output

 
0 Kudos
Don't
move!

While working on JSP running on TOMCAT I noticed that when views the source of the outputted jsp there is to much whitespace in the source. In order to remove all the unnecessary whitespace from the output thereby saving on bandwidth is to do the following (for tomcat).

Fine the web.xml located in the conf folder of tomcat installation directory. Find the
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
and replace it with the following
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>trimSpaces</param-name>
<param-value>true</param-value>
</init-param>

<load-on-startup>3</load-on-startup>
</servlet>

Then just restart tomcat

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

24. January 2008 by Nilesh Manohar
Categories: Computers, Web Development | Tags: , , | 2 comments