[i][b]1. Jsp 页面 动态和静态 include 指令的不同[/b][/i]
静态: index.jsp
<%@ include file="MyJsp.jsp" %>
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
<%= [b]Here we can use instance variable declared in MyJsp.jsp page[/b] %>
</body>
</html>
动态:
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
<jsp:include page="index.jsp" />
<%= [b]Here we can not use instance variable declared in MyJsp.jsp page[/b] %>
</body>
</html>
总结 :
静态 include 指令是将 MyJsp.jsp 页面完全整合到 index.jsp 页面中,只生成[b]一个 servlet[/b]。
动态 include 指令虽然也将 MyJsp.jsp 页面包含到 index.jsp 页面中,但是该指令生成的是[b]两个 servlet[/b],各页面分别编译为[b]一个 servlet[/b]。
[i][b]2. 超链接提交表单,并打开新窗口(在新页面中获取表单值)[/b][/i]
<form name="myForm" method="post" action="MyJsp.jsp" [b]target="_blank"[/b]>
<input type="hidden" name="attr1" value="test1">
<a href="" [b]οnclick="javascript:myForm.submit();"[/b]>Submit</a>
</form>
静态: index.jsp
<%@ include file="MyJsp.jsp" %>
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
<%= [b]Here we can use instance variable declared in MyJsp.jsp page[/b] %>
</body>
</html>
动态:
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
<jsp:include page="index.jsp" />
<%= [b]Here we can not use instance variable declared in MyJsp.jsp page[/b] %>
</body>
</html>
总结 :
静态 include 指令是将 MyJsp.jsp 页面完全整合到 index.jsp 页面中,只生成[b]一个 servlet[/b]。
动态 include 指令虽然也将 MyJsp.jsp 页面包含到 index.jsp 页面中,但是该指令生成的是[b]两个 servlet[/b],各页面分别编译为[b]一个 servlet[/b]。
[i][b]2. 超链接提交表单,并打开新窗口(在新页面中获取表单值)[/b][/i]
<form name="myForm" method="post" action="MyJsp.jsp" [b]target="_blank"[/b]>
<input type="hidden" name="attr1" value="test1">
<a href="" [b]οnclick="javascript:myForm.submit();"[/b]>Submit</a>
</form>