package servlet;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
public class Register extends javax.servlet.http.HttpServlet {
private void doProcess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
String studentName = request.getParameter("studentName");
String pairname = request.getParameter("pairname");
String parentname = request.getParameter("parentname");
String p1 = request.getParameter("password");
String p2 = request.getParameter("password2");
String type = request.getParameter("catagloryID");
System.out.println("studentName" + studentName);
System.out.println("pairname" + request.getParameter("pairname"));
System.out.println("parentname" + request.getParameter("parentname"));
System.out.println("password" + p1);
System.out.println("password2" + p2);
HttpSession session = request.getSession();
session.setAttribute("studentName",studentName);
session.setAttribute("pairname",pairname);
session.setAttribute("parentname",parentname);
if(type == null)
{
session.setAttribute("wrongMsgType","必须选择其中之一");
}
if(type == "1")
{
System.out.println("catagloryID" + "初中英语");
}
else if(type == "2")
{
System.out.println("catagloryID" + "TOEFL");
}
else if(type == "5")
{
System.out.println("catagloryID" + "高中英语");
}
else if(type == "6")
{
System.out.println("catagloryID" + "GRE");
}
else if(type == "7")
{
System.out.println("catagloryID" + "SAT");
}
request.setAttribute("studentName",studentName);
request.setAttribute("pairname",pairname);
request.setAttribute("parentname",parentname);
if(!p1.equals(p2))
{
session.setAttribute("wrongMsgPw","两次密码不同");
}
request.getRequestDispatcher("register.jsp").forward(request,response);
}
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
doProcess(request,response);
}
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
doProcess(request,response);
}
}
 <%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Register User</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="English word">
</head>
<style>
h7 {
color:red;
}
</style>
<body bgcolor="#DFFFBF">
<h1>注册信息:</h1>
<hr/> <form id="registerForm" name="registerForm" method="post" action="Register" >
<table>
<tr> </tr>
<tr align="left">
<td align="right" width="100px" class="inputLabel">学生姓名: </td>
<td align="left" width="100px">
<%-- 方法一 使用if-else实现输出和不输出--%>
<%-- <%--%>
<%-- if(request.getAttribute("studentName") != null){--%>
<%-- %>--%>
<%-- <input class="inputFrame" type="text" id="studentName" name="studentName" value="<%=request.getAttribute("studentName")%>"></td>--%>
<%-- <td align="right" width="100px" class="inputLabel">帮背者姓名:</td>--%>
<%-- <td align="left" width="100px"><input class="inputFrame" type="text" id="pairname" name="pairname" value="<%=request.getAttribute("pairname")%>"></td>--%>
<%-- <td align="right" width="100px" class="inputLabel">父母姓名 :</td>--%>
<%-- <td align="left" width="100px"><input class="inputFrame" type="text" id="parentname" name="parentname" value="<%=request.getAttribute("parentname")%>"></td>--%> <%-- <%--%>
<%-- }else{--%>
<%-- %>--%>
<%-- <input class="inputFrame" type="text" id="studentName" name="studentName" value=""></td>--%>
<%-- <td align="right" width="100px" class="inputLabel">帮背者姓名:</td>--%>
<%-- <td align="left" width="100px"><input class="inputFrame" type="text" id="pairname" name="pairname" value=""></td>--%>
<%-- <td align="right" width="100px" class="inputLabel">父母姓名 :</td>--%>
<%-- <td align="left" width="100px"><input class="inputFrame" type="text" id="parentname" name="parentname" value=""></td>--%> <%-- <%--%>
<%-- }--%>
<%-- %>--%>
<%-- 方法二,使用el,自动回填--%>
<input class="inputFrame" type="text" id="studentName" name="studentName" value="${studentName}"></td>
<td align="right" width="100px" class="inputLabel">帮背者姓名:</td>
<td align="left" width="100px"><input class="inputFrame" type="text" id="pairname" name="pairname" value="${pairname}"></td>
<td align="right" width="100px" class="inputLabel">父母姓名 :</td>
<td align="left" width="100px"><input class="inputFrame" type="text" id="parentname" name="parentname" value="${parentname}"></td> </tr>
<tr align="left">
<td align="right" width="100px" class="inputLabel">密码:</td>
<td align="left" width="100px"><input class="inputFrame" type="password" id="password" name="password" > </td>
<td align="right" width="100px" class="input.label">确认密码:</td>
<td><input class="inputFrame" type="password" id="password2" name="password2">
<td>
<%
String pwMsg = (String)session.getAttribute("wrongMsgPw");
if(pwMsg != null)
out.println("<h7>" + pwMsg + "</h7>");
session.setAttribute("wrongMsgPw",null);
%>
</td>
<td></td>
</tr>
<tr>
<td colspan="4" class="alert">
<div id="checkUser"> </div> </td>
</tr>
<tr height="5px">
<td colspan="6">请选择需要背的单词(后期可更改):
<%
String typeMsg = (String)session.getAttribute("wrongMsgType");
if(typeMsg != null)
out.println("<h7>" + typeMsg + "</h7>");
session.setAttribute("wrongMsgType",null);
%>
</td>
</tr> <tr><td align="center"><input type="radio" id="catagloryID1" name="catagloryID" value="6"></td>
<td align="center" colspan="3">GRE</td>
</tr> <tr><td align="center"><input type="radio" id="catagloryID1" name="catagloryID" value="2"></td>
<td align="center" colspan="3">TOEFL</td>
</tr> <tr><td align="center"><input type="radio" id="catagloryID1" name="catagloryID" value="7"></td>
<td align="center" colspan="3">SAT</td>
</tr> <tr><td align="center"><input type="radio" id="catagloryID1" name="catagloryID" value="5"></td>
<td align="center" colspan="3">高中英语 </td>
</tr> <tr><td align="center"><input type="radio" id="catagloryID1" name="catagloryID" value="1"></td>
<td align="center" colspan="3">初中英语 </td>
</tr> <tr height="5px"></tr>
<tr><td colspan="4" align="center"><input class="button gray" type="submit" value="Submit" ></td> </tr>
</table> </form>
<p class="tips">&nbsp;</p>
</body>
</html>

最新文章

  1. 一段良好的程序永远不应该发生panic异常
  2. [ACM训练] 算法初级 之 基本算法 之 枚举(POJ 1753+2965)
  3. Java并发编程:Thread类的使用
  4. 如何申请国际版Office365和Azure的试用账号
  5. mysql 日期
  6. UI:页面传值、单例模式传值、属性传值、NSUserDefaults 数据持久化
  7. On-board diagnostics -- Standards documents
  8. 【WCF--初入江湖】08 并发与实例模式
  9. Ubuntu 12.04LTS 找不到eth0网卡
  10. 在模型中获取网络数据,刷新tableView
  11. C语言中的字符串截取函数
  12. 基于linux c的mysql操作——幼儿园数据管理系统
  13. spring利用扫描方式对bean的处理(对任何版本如何获取xml配置信息的处理)
  14. 文件下载:&quot;Content-disposition&quot;,&quot;attachment; filename=中文名&gt;&gt;&gt;解决方案
  15. 【java设计模式】之 建造者(Builder)模式
  16. Linux 下按时间顺序批量删除文件
  17. mysql基础之yum安装mysql5.7.18
  18. java中的位操作
  19. 快速搭建BIND服务,并实现解析
  20. Python数值计算之插值曲线拟合-01

热门文章

  1. BZOJ 4128: Matrix (矩阵BSGS)
  2. Windows系统下载地址
  3. 【51nod 1667】概率好题
  4. docker安装redis并允许外网访问
  5. nginx信号
  6. 关于java代理(静态代理和动态代理)
  7. SDOI2019R2游记
  8. jq获取页面中checkbox已经选中的checkbox
  9. vue添加外部js
  10. Keras学习笔记一:修改数据读入方式为本地图片读入