How to delete empty lines after JSP Compilation

Source: Internet
Author: User

The method for deleting empty lines after JSP compilation is as follows:

1. JSP 2.1 + is supported. The following code is contained in each page to be empty rows:

 
 
  1. <%@ page trimDirectiveWhitespaces="true" %> 

The JSP compilation is successfully tested under Tomcat 6.0.14.

2. Support servlet 2.5 +, that is, the XSD version of web. xml is 2.5. Add the following code to web. xml:

 
 
  1. <jsp-config> 
  2. <jsp-property-group> 
  3. <url-pattern>*.jsp</url-pattern> 
  4. <trim-directive-whitespaces>true</trim-directive-whitespaces> 
  5. </jsp-property-group> 
  6. </jsp-config> 

The JSP compilation is successfully tested under tomcat 6.0.14.

3. Tomcat 5.5.x +. In the Tomcat installation directory/conf/web. xml, find the servlet named "jsp" and add the following code:

 
 
  1. <init-param> 
  2. <param-name>trimSpaces</param-name> 
  3. <param-value>true</param-value> 
  4. </init-param> 

I have never tested it, but the help of the web. xml file in tomcat said so.

TrimSpaces shocould white spaces in template text between actions or directives be trimmed? [False]

In actual operations, I added the 5.5 configuration to the page and started tomcat several times repeatedly, but it was still unsuccessful. Then I thought that JSP has been compiled into servlet, so it could not be changed, go to the work directory in tomcat and delete all the JSP-compiled classes. Wow, the whole world is clean and empty lines are successfully deleted.

  1. Functions and principles of several encodings in JSP and Servlet
  2. Introduction to JSP: several solutions to avoid repeated submission of Form forms
  3. Five Aspects to get started with JSP
  4. How to Set Up JSP development and running environment
  5. Introduction to JSP page Jump and request forwarding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.