Two include in jsp

xiaoxiao2021-03-06  96

There are two ways to include files in JSP:

1. <% @ include file = "import.jsp"%>

2.

When using the first write method, the included file is incorporated in a static form to the current JSP file. That is, the file content you want to include is first inserted into the location of the include statement, and then compile the file. The file it contains is not compiled.

It can be seen in the working directory of Tomcat that import.jsp is not automatically compiled as .java files.

It contains .jsp and .htm files are no different from this approach.

When using the second write method. It is to compile Import.jsp first, then the output of Import.jsp is included in the current file.

When the parameter flush is true, each execution will reinterpret the file IMPORT.JSP. Each time you access this page, you will recompile the included file and affect the speed.

When the parameter flush is false, it will be read from the cache, and the response speed is fast, but when modifies the included file, it is not possible to react it in time, it is necessary to restart the application server (Tomcat) or delete the included system. Document (import_jsp.java).

In Tomcat's working directory, IMPORT.JSP can be seen automatically into import_jsp.java.

The .jsp file is included, the execution result is included, and the .htm file, directly contain the file content.

<% @ include%> is compiled, is a runtime. The former is equivalent to the macro, compiles, and the latter is equivalent to the function and returns when running.

Reference:

Article: JSP Best Practices: Control Dynamic Content with JSP: Include

Http://www-900.ibm.com/developerWorks/cn/java/J-JSP04293/

转载请注明原文地址:https://www.9cbs.com/read-123384.html

New Post(0)