<%@ page contentType="text/html; charset=gb2312"%>
<%@ page import="java.util.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>示例程序：显示错误</title>
<style type="text/css">
<!--
.style3 {
	font-size: 18px;
	font-weight: bold;
}
.style4 {
	font-size: 18px;
	font-weight: bold;
	color: #FF0000;
}
.style5 {color: #FF0000}
-->
</style>
</head>

<%
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	String confirmPassword = request.getParameter("confirmPassword");
	String gender = request.getParameter("gender");
	String age = request.getParameter("age");
	
	List errorMsgs = new ArrayList();
	if ( username == null || username.equals("")){
		username="";
		errorMsgs.add(new String("用户名不能为空"));
	}
	if ( password == null || password.equals("")){
		password="";
		errorMsgs.add(new String("密码名不能为空"));
	}
	if ( gender== null ){
		gender="";
	}
	
	if ( confirmPassword == null || !confirmPassword.equals(password)){
		confirmPassword=confirmPassword!=null?confirmPassword:"";
		errorMsgs.add(new String("密码与确认密码不一致"));
	}
	if ( age == null || age.equals("")){
		age="";
		errorMsgs.add(new String("年龄不能为空"));
	}
%>
<body>
<%
if ( errorMsgs.size() > 0 ){
	String error ;
	for(int i=0;i<errorMsgs.size();i++){
		error = (String)errorMsgs.get(i);
%>
<span class="style4"><%=error%><br>
<%}%>
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <form name="theform" action="checkForm.jsp" method="post">
  <tr>
    <td align="center"><span class="style3">示例程序：用户注册信息</span></td>
  </tr>
  <tr>
    <td><table width="500" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="192" align="right">用户名：</td>
        <td width="308">&nbsp;<input name="name" type="text" id="name" size="16" value="<%=username%>"></td>
      </tr>
	  <tr>
        <td width="192" align="right">密码：</td>
        <td width="308">&nbsp;<input name="password" type="password" id="name" size="16" value="<%=password%>"></td>
      </tr>
	  <tr>
        <td width="192" align="right">确认密码：</td>
        <td width="308">&nbsp;<input name="confirmpassword" type="password" id="name" size="16" value="<%=confirmPassword%>"></td>
      </tr>
      <tr>
        <td align="right">性别：</td>
        <td>&nbsp;<input name="gender" type="radio" value="男" <%if(gender.equals("1")){%><%="checked"%> <%}%>>
          男 
            &nbsp;<input name="gender" type="radio" value="女" <%if(gender.equals("0")){%><%="checked"%> <%}%>> 
            女 </td>
      </tr>
      <tr>
        <td align="right">年龄：</td>
        <td> &nbsp;<input name="age" type="text" id="age" size="6" value="<%=age%>"></td>
      </tr>
    </table></td>
  </tr>
  
  <tr>
    <td align="center"><input type="submit" name="Submit" value="提交"></td>
  </tr>
  </form>
</table>
<%
}else{
%>
<center>恭喜您，注册成功!</center>
<%
}
%>
</body>
</html>
