Developers using JSP know that the HTML generated by the JSP compiled with a large number of blank lines, these white space generally does not matter, at most, reduce the friendliness of the search engine and HTML readability. However, when using JSP to generate XML files, if the "<?xml" header is not located in the first line of the head, the strict parser will error, like Opera browser.
This problem has plagued me for a long time, plus I have used a lot of taglib, such as jstl tags. Makes my HTML page a big chunk of a bald "white wasteland" that looks awkward. I've been searching the search engine for solutions, but only the questioner, there is no workaround. Today can not help but search a, and finally remove the blank line JSP left a better solution to this problem.
The original Tomcat 5.x added a parameter that specifies whether to remove spaces between the behavior and instructions in the template text. This is the problem of the JSP compiler or only by the compiler itself to solve more thorough.
The Tomcat 5.x version, which is the specification of JSP2.0 and Servlet2.4, is required to include the following bold-character configuration items in the Web.xml configuration.
<servlet>
<servlet-name >jsp</servlet-name>
<servlet-class> Org.apache.jasper.servlet.jspservlet</servlet-class>
<init-param>
< Param-name>trimspaces</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</ Load-on-startup>
</servlet>