JSP interview questions -- Differences Between include commands and include actions

Source: Internet
Author: User

Literally, both of them have meanings. In terms of running results, the functions of the two are similar, but the running process of the two is quite different.

<% @ Include %> the command is the compile-time syntax, that is, when compiling, copy the content of the target file pointed to by the command to the position where the command is located and replace the command, finally, a file is formed, and only one file is available during running.

<JSP: Include> the action is the runtime syntax. When the file containing the <JSP: Include> action is executed to this tag, it will switch to the target file pointed to by the execution tag, after the target file is executed, the content after the tag is executed. During running, two files are involved, just like method calls.

So when should I use the <% @ include %> command and the <JSP: Include> label? Because the <% @ include %> command is static and the <JSP: Include> command is dynamic, if a piece of code is executed, you can use the <% @ include %> command. If a piece of code may be executed but may not be executed, you can use <JSP: Include>.

In practical applications, the navigation part and the copyright part of many websites are the same and will appear in each file. Therefore, you can consider placing the content in a separate file, then use the <% @ include %> command to reference and use it.

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.