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)

2 thoughts on “stripping out extra spaces in JSP output

  1. I agree with everybody else: awesome story.! Much food for thought… It really made my day. Thank you.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. This post is inspiring, fresh and ultra awesome! You have a very progressive looks. Reading this blog is a great pleasure.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Comments are closed.