注册->显示注册信息->确认信息->根据选项跳转到相应页面
不管怎么样实现了呗,代码傻傻的,笨笨的,一点都不专业,嘿嘿
第一个页面:register.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <base href="<%=basePath%>"> 11 12 <title>用户注册</title> 13 14 <meta http-equiv="pragma" content="no-cache"> 15 <meta http-equiv="cache-control" content="no-cache"> 16 <meta http-equiv="expires" content="0"> 17 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 18 <meta http-equiv="description" content="This is my page"> 19 <!-- 20 <link rel="stylesheet" type="text/css" href="styles.css"> 21 --> 22 23 </head> 24 25 <body> 26 用户注册: 27 <form action="registerInto.jsp" id="userForm" name="userForm" method="post"> 28 用户名:<input type="text" name="userName" id="userName"/><br> 29 密码:<input type="password" name="password" id="password"/><br> 30 性别:<input type="radio" name="sex" id="sex" value="1">男 31 <input type="radio" name="sex" id="sex" value="0">女<br> 32 <input type="reset" value="重写"><input type="submit" value="提交"> 33 </body> 34 </html>
第二个:registerInto.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <base href="<%=basePath%>"> 11 12 <title>用户注册信息</title> 13 14 <meta http-equiv="pragma" content="no-cache"> 15 <meta http-equiv="cache-control" content="no-cache"> 16 <meta http-equiv="expires" content="0"> 17 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 18 <meta http-equiv="description" content="This is my page"> 19 <!-- 20 <link rel="stylesheet" type="text/css" href="styles.css"> 21 --> 22 23 </head> 24 25 <body> 26 <% 27 String userName = request.getParameter("userName"); 28 String password = request.getParameter("password"); 29 String sex = request.getParameter("sex"); 30 if(sex.equals("1")){ 31 sex="男"; 32 }else{ 33 sex="女"; 34 } 35 %> 36 请确认注册信息:<br> 37 用户名:<%=userName %><br> 38 密码:<%=password %><br> 39 性别:<%=sex %> 40 <form action="action.jsp" method="post"> 41 请确认:<br><input type="radio" name="check" value="1">确认无误 42 <input type="radio" name="check" value="0">重新填写<br> 43 <input type="submit" value="提交"> 44 </form> 45 </body> 46 </html>
第三个:action.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <base href="<%=basePath%>"> 11 12 <title>My JSP 'action.jsp' starting page</title> 13 14 <meta http-equiv="pragma" content="no-cache"> 15 <meta http-equiv="cache-control" content="no-cache"> 16 <meta http-equiv="expires" content="0"> 17 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 18 <meta http-equiv="description" content="This is my page"> 19 <!-- 20 <link rel="stylesheet" type="text/css" href="styles.css"> 21 --> 22 23 </head> 24 25 <body> 26 <% String pd = request.getParameter("check"); 27 if(pd.equals("1")){ 28 request.getRequestDispatcher("./success.jsp").forward(request,response); //定向的页面 29 }else{ 30 request.getRequestDispatcher("./register.jsp").forward(request,response); //定向的页面 31 } 32 %> 33 This is my JSP page. <br> 34 </body> 35 </html>
第四个页面:success.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <base href="<%=basePath%>"> 11 12 <title>My JSP 'success.jsp' starting page</title> 13 14 <meta http-equiv="pragma" content="no-cache"> 15 <meta http-equiv="cache-control" content="no-cache"> 16 <meta http-equiv="expires" content="0"> 17 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 18 <meta http-equiv="description" content="This is my page"> 19 <!-- 20 <link rel="stylesheet" type="text/css" href="styles.css"> 21 --> 22 23 </head> 24 25 <body> 26 恭喜你注册成功! <br> 27 </body> 28 </html>