<%@ page language=“java” contentType=“text/html; charset=utf-8”
pageEncoding=“utf-8”%>
<%!
String str = "全局变量";
%>
<%!
public void func() {
System.out.println("全局方法");
}
%>
<%!
class c{
private void f() {
System.out.println("全局类");
}
}
%>
<h1>静态包含</h1>
<%@ include file= "common/head.html" %>
<p>content</p>
<%@ include file="common/footer.jsp" %>
<h2>动态包含</h2>
<jsp:include page="common/head.html"/>
<p>content</p>
<jsp:include page="common/footer.jsp"/>
<body>
<jsp:forward page="target.jsp">
<jsp:param value="梁豪" name="userName"/>
<jsp:param value="123456" name="password"/>
</jsp:forward>
</body>
<body>
服务器内部跳转后的界面</br>
userName:<%=request.getParameter("userName") %></br>
password:<%=request.getParameter("password") %></br>
</body>