jsp:include and include directive

1.The <include> element allows you to include either a static or dynamic file in a JSP file. The results of including static and dynamic files are quite different. If the file is static, its content is included in the calling JSP file. If the file is dynamic, it acts on a request and sends back a result that is included in the JSP page. When the include action is finished, the JSP container continues processing the remainder of the JSP file. 2.The directive inserts a file of text or code in a JSP file at translation time, when the JSP file is compiled. When you use the directive, the include process is static. A static include means that the text of the included file is added to the JSP file. The included file can be a JSP file, HTML file, or text file. If the included file is a JSP file, its JSP elements are translated and included (along with any other text) in the JSP file. Once the included file is translated and included, the translation process resumes with the next line of the including JSP file. The included file can be an HTML file, a JSP file, a text file, or a code file written in the Java programming language. Be careful that the included file does not contain , , , or tags. Because the entire content of the included file is added to the including JSP file, these tags would conflict with the same tags in the including JSP file, causing an error. eg. Header.jsp Welcome!!! Contact.jsp <include page="Header.jsp"></include> difference between include directive and jsp:include there will be in the _jspService method of Contact_jsp.java. org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "Header.jsp", out, false); and Header_jsp.java file . if change the <include page="Header.jsp"></include> as there will be static { _jspx_dependants = new java.util.ArrayList(1); _jspx_dependants.add("/Header.jsp"); } at the declaration. and Header_jsp.java file does not exist.the info in the Header.jsp file will all insert into and in Contact_jsp.java </include>

你可能感兴趣的:(Directive)