PS: <% @ include> and <JSP: Include>
Why use include?#1
The include command is more powerful. The include command allows the contained files to contain JSP code that affects the home page, such as the settings of the response header and the definition of fields and methods.
#2.Static include command: The include page fully contains the code of the included page during compilation. Static inclusion also includes the compilation commands on the included pages. If the compilation commands on the two pages conflict, the page will fail.
#3.Action Command include -- Dynamic include: introduces the content of the imported page, and is ineffective by the compilation command of the imported page. The output of the contained page is included, the output of the contained page cannot contain JSP, but these pages can be the result of other resources.
#4.Use the include action or the include command?
Use the include command. If the included file changes, all the JSP pages that use it must be updated.
The include command should be used only when the include action cannot meet the requirements.
Some developers think that the code generated by the include command is executed faster than the code using the include action. Although this may be true in principle, the performance difference is very small, making it difficult to measure the workload. At the same time, the include action has a huge advantage in maintenance. When both methods can be used, the include action is almost certainly the preferred method.
Use the include action whenever possible for file inclusion. The include command should be used only when the fields or methods used on the home page are defined in the contained file, or when the contained file sets the response header on the home page.
Include commands and include actions