Java Web Job 1

Source: Internet
Author: User

The difference between include directives and include actions in JSP

1.include instruction is a file loading instruction

Include can insert JSP code into a JSP page before it is converted to a servlet. Its main advantage is its powerful functionality, which contains code that can contain JSP constructs that affect the main page in general, such as attributes, method definitions, and document type settings. Its disadvantage is that it is difficult to maintain as long as the included pages change, you have to change the main page, because the main page does not automatically see whether the contained pages have changed.

Syntax: <%include fil= "filename"%>

2.include Action

The <jsp:include> action is to include the output of the secondary page when the main page is requested. Although it is not possible to include JSP in the output of the contained pages, these pages can be the result of other resources. The server interprets the URL that points to the contained resource in a normal way, so the URL can be a servlet or JSP page. The server runs the contained page in the usual way, putting the resulting output in the main page, in a way that is consistent with the RequestDispatcher class's include method. The advantage is that there is no need to make changes to the main page when the included pages change. The disadvantage is that it contains the output of the secondary page, not the actual code of the secondary page, so there is no JSP construct that can affect the main page in general on the included page.

Syntax: <jsp:include page= "filename"/>

The include directive is the compile-time directive, where the contents of the files included in the include are inserted into the JSP file when compiling, and the JSP engine determines that the JSP page has not been modified, otherwise it is considered modified, because the contained files are inserted at compile time, So if you modify the Include file content without modifying the JSP, the resulting structure will not change, so execute the existing bytecode file directly without recompiling. Therefore, for content that does not change frequently, it is appropriate to use the include directive, which requires action elements if the required content is constantly changing.

Java Web Job 1

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.