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