jsp:include and include directive

来源:互联网 发布:linux挂载共享目录 编辑:程序博客网 时间:2024/05/22 12:27
1.The 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 <%@ include %> 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 <%@ include %> 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.jspWelcome!!!Contact.jspdifference between include directive and jsp:includethere 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 as <%@include file="Header.jsp"%>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
原创粉丝点击