JSP removes blank lines left by Jstl tag Library "include, taglib", etc.

Source: Internet
Author: User

When doing the project, often use to Jstl and El expression, sometimes we need to look at the page generated source code, but when the JSP is full of jstl of various tags, the page will have a lot of blank parts, sometimes too many will let the browser suspended animation, this is we want to remove these blank parts. There are many ways to get rid of them, listed below.

My development and Server environment: Windows7 + Eclipse2014 + Tomcat7.0 + JDK 1.7.0

After multiple tests, the available methods are:

1. Add a piece of code to the head of each JSP <%@ page trimdirectivewhitespaces= "true" %>

2. Add a JSP script code on the page <%out.clear ();%>

3. Add the following configuration to the project's Web. XML

4.Configuring Web. Xml with Tomcat

 <servlet> <ser Vlet-name>jsp</servlet-name> <SERVLET-CLASS>ORG.APACHE.JASPER.SERVLET.JSPSERVLET</SERVLET-CLA ss> <init-param> <param-name>fork</param-name> <param-value& gt;false</param-value> </init-param> <init-param> <param-name>xp          Oweredby</param-name> <param-value>false</param-value> </init-param>    <init-param> <param-name>trimspaces</param-nam E> <param-value>true</param-value> </init-param>      <load-on-startup>3</load-on-startup> </servlet>  
Note: You need to clear the re-release to start the role!


Step: Stop,clean...,publish,start

I tried it just in the beginning. All methods do not work, only to think of republishing.




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.