c.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>测试包含</title>
</head>
<body>
cccc
<%@ include file="/a.jsp" %>
<jsp:include page="/b.jsp"></jsp:include>
</body>
</html>
a.jsp
aaaa
b.jsp
bbbb
清除 tomcat 下 work目录文件
请求 c.jsp文件
查看编译后的 .class
修改a.jsp的内容为
aaaa --- aaaa
重新请求 c.jsp
修改b.jsp
bbbb --- bbbbb
刷新 c.jsp
查看编译后的效果
总结: 1.<%@ include file="..."%>:包含页和被包含页融为一体,只生成一个.class文件
2.<jsp:include page="..."></jsp:include>包含页和被包含页是两个独立体,只是包含页调用一下被包含页而已。