Use include to prevent pagesCodeRedundant and repetitive, and standardized layout, only one containing statement can be used for code reuse to improve efficiency, as shown below:
1> include command: <% @ include file = "relativeurl" %>, and relativeurl is the applicationProgramPath of another JSP or HTML file. For example, if all pages in the website have a uniform navigation bar head. jsp or script copyright foot. jsp, you can use the include command. That is, the include command is used to implement the blockchain of JSP pages.
The sample code is as follows:
<% @ Pagelanguage = "Java" conenttype = "text/html; charset = UTF-8" %>
<% @ Brief defile = "head. jsp" %>
...
<% @ Shortdefile = "foot. jsp" %>
2> <JSP: Include/> behavior: <JSP: Include page = "relativeurl" Flush = "true"/> attribute page is required and is the relative path of the included file, must be a file in this web application. The value range of the flush attribute is true or false. The default value is false. Set whether to clear the cache before reading the content of the saved file.
The sample code is as follows:
<% @ Pagelanguage = "Java" contenttype = "text/html; charsert = UTF-8" %>
<JSP: includeflush = "true" page = "/head. jsp?> </Jsp: Include>
Here is the text
<JSP: includeflush = "true" page = "/foot. jsp"> </jsp: Include>
The difference between the two: although the include command and the include action can contain a file, the principle of the two is different from that of the include action at the time of occurrence. The former is "first include, then compile", which is included in the compilation, includingSource codeWhile the latter includes "run first, then include" at runtime, and only contains the running result. The include action applies to request. getrequestdispatcher ("relativeurl"). Forward (request. Response) to execute the contained file.