Developers who use JSP know that the HTML generated after JSP compilation contains a large number of blank lines. These blank lines are generally not in the way, which at most reduces the friendliness of search engines and the readability of HTML. However, when JSP is used to generate an XML file? If the xml header is not at the top of the first line, the strict parser will report an error, such as operabrowser.
This problem has plagued me for a long time, and I have used a lot of taglib, such as jstl labels. As a result, a large piece of bald white wasteland on my HTML page looks awkward. I have been searching for a solution in the search engine, but only the questioner has no solution. Today, I couldn't help searching for another one, and finally removed the blank lines left by JSP to better solve this problem.
In the past, Tomcat 5.x added a parameter to specify whether to remove spaces between behaviors and commands in the template text. This is a problem with the JSP compiler, which can only be completely solved by the compiler itself.
Tomcat 5.x version is required, that is, jsp2.0 and servlet2.4 specifications. Add the following 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>