Three methods for introducing one jsp page and three methods for introducing static and dynamic jsp pages

Source: Internet
Author: User

Three methods for introducing one jsp page and three methods for introducing static and dynamic jsp pages

1. First: jstl import

<C: import url = "inlayingJsp. jsp"> </c: import>

2. Type 2: jsp include command

The include command tells the container to copy all the content summarized by the included file and paste it into the file.

<% @ Include file = "inlayingJsp. jsp" %>

3. Third: jsp include action

<Jsp: include page = "inlayingJsp. jsp" flush = "true"/>

Note: (1) the include command inserts the source code of "Header. jsp" during conversion, while the <jsp: include> action inserts the response of "Header. jsp" at runtime.

<% @ Include is static. <% @ include, regardless of the txt text or jsp file, the contained pages are not re-compiled.

<% @ Include is a static inclusion. When several JSP files are translated into servlet, several class files are generated, if the variable I is defined in jsp1 and the variable I is also defined in jsp2, compilation will fail,

The jsp Container will tell you that I has already defined it.

<Jsp: include is dynamic inclusion. <jsp: include includes jsp files. This means that the included pages must be re-compiled every time the home page is loaded.

That is to say, no matter how many jsp pages you contain are translated into servlet, there is a class file.

Therefore, use the <% @ include option with caution!

(2) when using the jstl label, be sure to add the following code in the jsp file header: <% @ taglib prefix = "c" uri = "https://Java.sun.com/jsp/jstl/core" %>

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.