a.jsp:
<%@ page language="java" import="java.util.Random" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%!
//jsp声明片段:注意,不建议在jsp页面定义变量或方法
String a="abc";
int i=2;
public void printName(){
System.out.println(a);
}
%>
<!-- jsp表达式语法 -->
<%=new java.util.Date() %>
<!-- 脚本 -->
<%
printName();
%>
<%--
page指令:指明与jsp容器的沟通;import属性可以多次使用。也可以连着写用逗号
include指令:
a.静态包含<%@include file="fileURL"%>
b.动态包含
taglib指令
--%>
<jsp:include page="b.jsp" flush="true">
<jsp:param value="tomcat" name="name"/>
<jsp:param value="女" name="sex"/>
</jsp:include>
<form action="c.jsp">
<input type="text" name="age" value="12">
<input type="submit">
</form>
<%--创建对象,调用默认的构造方法 --%>
<jsp:useBean id="person" class="com.fill.bean.Person"></jsp:useBean>
<%--设置对象属性值 --%>
<jsp:setProperty property="name" name="person" value="xiaio"/>
<%--获取 --%>
<jsp:getProperty property="name" name="person"/>
</body>
</html>
b.jsp<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String name=request.getParameter("name");
out.println("nv de ha"+name);
%>
</body>
</html>
c.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:forward page="d.jsp"></jsp:forward>
</body>
</html>
d.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String age=request.getParameter("age");
out.println(age+"ggg");
%>
</body>
</html>