//注册界面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '1.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form action="2.jsp" method="post">
用户名:<input type="text" name="txtname" value="<%=request.getAttribute("name")%>"/>
密码: <input type="password" name="txtpwd"/>
<br/>
爱好:<input type="checkbox" name="hoddy" value="p"/>跑
<input type="checkbox" name="hoddy" value="t"/>跳
<input type="checkbox" name="hoddy" value="w"/>玩
<br/>
<input type="submit" name="txtsub"/>
</form>
</body>
</html>
//提交界面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '1.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String name=request.getParameter("txtname");
String name1=request.getParameter("txtpwd");
String[] name2=request.getParameterValues("hoddy");
if(name.equals("sa")&&name1.equals("sa")){
//作用域保存
request.setAttribute("name2",name2);
request.setAttribute("name",name);
request.setAttribute("name1", name1);
request.getParameterValues(name);
request.getRequestDispatcher("/3.jsp").forward(request, response);
}else{
request.setAttribute("name", name);
request.getRequestDispatcher("/1.jsp").forward(request, response);
}
%>
</form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '3.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
欢迎: <%=request.getAttribute("name") %>
<br/>
密码: <%=request.getAttribute("name1") %>
</body>
</html>