定义一个logind的jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%><!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>用户登录</h1>
<hr>
<form action="forward.jsp" name="loginForm" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password"/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="登录"></td>
</tr>
</table>
</body>
</html>
定义一个param
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="pragma" content="no-cache">
<title>Insert title here</title>
</head>
<body>
<h1>forward 动作</h1>
<jsp:forward page="user.jsp">
<jsp:param value="admin@123.net" name="email"/>
</jsp:forward>
</body>
</html>
定义一个user
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>用户资料</h1>
<%
String username="";
String password = "";
String email="";
if(request.getParameter("username")!=null){username = request.getParameter("username");
}
if(request.getParameter("password")!=null){password= request.getParameter("password");
}
if(request.getParameter("email")!=null){email= request.getParameter("email");
}
%>
用户名:<%=username %>
密码:<%=password %>>
电子邮箱:<%=email %>
</body>
</html>
运行结果