stripping out extra spaces in JSP output

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

1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 2.71 out of 5)
Loading ... Loading ...

About Nilesh Manohar

Web Developer
This entry was posted in Computers, Web Development and tagged , , . Bookmark the permalink.

2 Responses to stripping out extra spaces in JSP output

  1. Men Mind says:

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

  2. Daze says:

    This post is inspiring, fresh and ultra awesome! You have a very progressive looks. Reading this blog is a great pleasure.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>