jsp:include and include directive

本文详细解释了JSP中两种不同包含方式的区别:静态包含(include指令)与动态包含(<jsp:include>元素)。静态包含在编译阶段将文件内容插入到包含文件中,而动态包含则是在运行时请求指定资源并将结果插入页面。
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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值