望各位大人帮我解惑 小女子感激不尽
JSP中动态INCLUDE与静态INCLUDE的区别?
答:动态INCLUDE用jsp:include动作实现 它总是会检查所含文件中的变化静态INCLUDE用include伪码实现,定不会检查所含文件的变化
甚么叫 检测变化啊
[此贴子已经被作者于2007-5-23 21:41:11编辑过]
我自己写了一个测试 发现它都会变化啊
我用Myjsp分别动态调用Myjsp1和静态调用MyJsp2 当我刷新Myjsp的时候时间都会变啊 那还有甚么动态静态之说呢???
想不明白啊
=====MyJsp.jsp======
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>Time change</title>
</head>
<body>
<%@ include file="MyJsp2.jsp" %>
<jsp:include flush="true" page="MyJsp1.jsp"></jsp:include>
</body>
</html>
==============MyJsp1.jsp=====
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<%
long time = System.currentTimeMillis();
%>
<%=time %>
</body>
</html>
=========MyJsp2.jsp======
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<body>
<%
long time = System.currentTimeMillis();
%>
<%=time %>
</body>
</html>
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
public final class MyJsp_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static java.util.List _jspx_dependants;
static {
_jspx_dependants = new java.util.ArrayList(1);
_jspx_dependants.add("/MyJsp2.jsp");
}
public Object getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("<html>\r\n");
out.write(" <head>\r\n");
out.write(" <title>Time change</title>\r\n");
out.write(" </head>\r\n");
out.write(" <body>\r\n");
out.write(" ");
out.write("\r\n");
out.write(" ");
long time = System.currentTimeMillis();
out.write("\r\n");
out.write(" ");
out.print(time );
out.write("\r\n");
out.write(" ");
out.write("\r\n");
out.write(" ");
out.write("\r\n");
out.write(" </body>\r\n");
out.write("</html>\r\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
所生成的servlet 为什么不是两个response.setContentType("text/html;charset=UTF-8");它不是静态包含吗?