The jsp-config of label definitions in Web-xml in Java Web

Source: Internet
Author: User

<jsp-config> includes <taglib> and <jsp-property-group> two child elements.

Where the <taglib> element already exists at JSP 1.2, and <jsp-property-group> is the new element of JSP 2.0.
The <jsp-property-group> element consists of eight sub-elements, each of which are:
1.<description>: Description of the setting;
2.<display-name>: set name;
3.<url-pattern&gt: The range of values affected by the setpoint, such as:/ch2 or/*.jsp;
4.<el-ignored&gt: True to indicate that El syntax is not supported;
5.<scripting-invalid&gt: True to indicate that <% scripting%> syntax is not supported;
6.<page-encoding>: Set the encoding of the JSP Web page;
7.<include-prelude&gt: Sets the header of the JSP Web page with the extension. JSPF;
8.&LT;INCLUDE-CODA&GT: Sets the end of the JSP Web page with the extension. JSPF.
A simple <jsp-config> element complete configuration:
<jsp-config>
<taglib>
<taglib-uri>Taglib</taglib-uri>
<taglib-location>/WEB-INF/tlds/MyTaglib.tld</taglib-location>
</taglib>
<jsp-property-group>
<description>special Property Group for JSP Configuration JSP example.</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>/jsp/* </url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/include/prelude.jspf</include-prelude>
<include-coda>/include/coda.jspf</include-coda>
</jsp-property-group>
</jsp-config>


In fact, not all of the attributes in Web. XML are used, such as the following example:

<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>

tags that use JSP tags and jstl are often used in JSPs, such as <%@ page. %>, <%@ taglib ...%>, <c:foreach....%> In particular, loop labels, which produce a large number of empty lines in the HTML of the final output of the JSP, resulting in degraded performance. The most convenient workaround is to add the following settings in Web. xml

There are two ways to solve this problem

1, in Web. xml

<jsp-property-group>

<url-pattern>*.jsp</url-pattern>

<trim-directive-whitespaces>true

</trim-directive-whitespaces>

</jsp-property-group>

2, add the header to each JSP file

<%@ page trimdirectivewhitespaces= "true"%>

The jsp-config of label definitions in Web-xml in Java Web

Related Article

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.