What are the include in JSP? What is the difference ?, Jspinclude

Source: Internet
Author: User

What are the include in JSP? What is the difference ?, Jspinclude

What are the include in JSP? What is the difference?


1. What are the include items in JSP?

(1) <% @ include file = "" %>

(2) <jsp: include page = "" flush = "true"/>


2. Differences

(1) The former is an indicator element, and the latter is a behavior element.

(2) The former is merged into a page, and the latter is merged into a file and then converted into a Servlet by the JSP Container


What is $ {} used in the jsp webpage? <jsp: What is different from <%, <jsp: include is different from <% include,

$ {...} It is an EL expression language that can simplify access to jsp built-in objects. It can easily implement conditional output without using JAVA programming, eliminating the need for most types of conversions. The simplest example <Body>
4 + 5 =$ {4 + 5} <br>
5*2 =$ {5*2}
</Body>
</Html>
The page displays 4 + 5 = 9
5*2 = 10
This is a simple example, but the problem is that simplified languages avoid many types of conversions.
<% Include> is a command element and static inclusion. The execution time is in the compilation phase, and the introduced content is a static file. It is integrated with the inclusion when compiled into servlet, therefore, the file of include cannot be a variable or be followed by any parameter after file.
<Jsp: include> is an action element and a dynamic inclusion. The execution time is in the request stage. The introduced content is dynamically generated when the execution page is requested and then included in the page.

What is the difference between the include command and the <jsp: include> action in jsp?

Simply put:
The include command is used to add the JAVA code (Source Code) of other pages, which is combined with the code of this page. It is equivalent to copying the source code from that page to this page, and then compiling. So variables can be shared. Because the source code of other files is already included in the compilation of this page, this page will be ignored when other pages are changed in the future, because it has already been compiled.
<Jsp: include> an action is to add the HTML result page after the code of the two pages is run to the HTML result page after the page is run. Therefore, variables cannot be shared.

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.