⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 register.jsp

📁 一个JSP范例
💻 JSP
字号:
        <%@ page errorPage="ErrPage.jsp"
	         import="java.util.Date, java.sql.*"
	         contentType="text/html;charset=gb2312"%>
	<jsp:useBean id="pool" scope="application" class="com.PoolBean"/>
	<HTML>
	<HEAD>
	<SCRIPT LANGUAGE="JavaScript" SRC=" meeting.js"></SCRIPT>
	<script language="JavaScript" type="text/Javascript">
	<!--
	function isok(theform)
	{
	  if (theform.user_code.value=="") 
	  {
		    alert("请您填写用户名!");
		    theform.user_code.focus();
		    return (false);
	   }
	  var verifyusercode;	
	  var intverifySrc; 
	  var intIndex;
	  var usercode=theform.user_code.value;
	  verifyusercode = theform.verify.value;
	  intIndex = verifyusercode.indexOf(usercode); 	
	  if (!(intIndex == -1))
	  {
		alert("此用户名已被使用,请重新输入!");
		theform.user_code.value="";
		theform.user_code.focus();
		return false;
	  }
	  if (theform.user_name.value=="") 
	  {
		    alert("请您填写真实姓名!");
		    theform.user_name.focus();
		    return (false);
	   }
	  if (theform.user_password.value=="") 
	  {
		    alert("请您填写用户密码!");
		    theform.user_password.focus();
		    return (false);
	   }
	   var user_password =theform.user_password.value;
	   var confirm_password =theform.confirm_password.value;
	   if (!(user_password==confirm_password))
	  {
	    alert("您填入的密码不一致,请重新输入!");
		theform.user_password.value="";
		theform.confirm_password.value="";
	    theform.user_password.focus();
	    return (false);
	  }
	  if (theform.user_sex.value=="") 
	  {
		    alert("请您选择性别!");	    
		    return (false);
	   } 
	   if (theform.user_year.value=="") 
	   {
		    alert("请您填写出生日期的年份!");
		    theform.user_year.focus();
		    return (false);
	   }	
	  var getformyear;
	      getformyear= theform.user_year.value; 	
	  var int_year= isintnumber(getformyear);  
	  if (!int_year)
	  {
		    alert("您填入的出生日期中的年有错误!");
			return false;
	  } 
	  var int_year_len=getformyear.length;
	  if(int_year_len!=4)
	  {
	      alert("您填入的出生日期中的年是四位数!");
			return false;     
	  }
	  var getformmonth;
	     getformmonth = theform.user_month.value;
	  var getformday;
	     getformday = theform.user_day.value; 
	  var subreturndate;
	  subreturndate=0; 
	  subreturndate = isrightdate(getformyear,getformmonth,getformday);
	  if (subreturndate == 1)
	  {
	     alert(getformyear+"年"+getformmonth+"月只有三十天,请您重新填写日期!");
		 return false;
	  }
	  if (subreturndate == 2)
	  {
	     alert(getformyear+"年二月只有29天,请您重新填写日期!");
	 return false;
	  }
	  if (subreturndate == 3)
	  {
	     alert(getformyear+"年二月只有28天,请您重新填写日期!");
		 return false;
	  }  
	  if (theform.user_duty.value=="") 
	  {
		    alert("请您填写职称或职务!");
		    theform.user_duty.focus();
		    return (false);
	   }
	   if (theform.user_workplace.value=="") 
	  {
		    alert("请您填写工作单位!");
		    theform.user_workplace.focus();
		    return (false);
	   }
	    if (theform.user_address.value=="") 
	  {
		    alert("请您填写通信地址!");
		    theform.user_address.focus();
	    return (false);
	   }
	   if (theform.user_tel.value=="") 
	  {
		    alert("请您填写联系电话!");
		    theform.user_tel.focus();
		    return (false);
	   }
	    if (theform.user_email.value=="") 
	  {
		    alert("请您填写电子箱信地址!");
		    theform.user_email.focus();
		    return (false);
	   }
	return (true); 	 
	}
	function onClick()
	{ 
		this.location.replace("Login.jsp");
	}
	-->
	</script>
	<LINK REL="stylesheet" HREF="littleproject.css" TYPE="text/css">
	<TITLE>会务管理首页</TITLE>
	</HEAD>
	<BODY bgcolor=LightBlue>
	<%
	Date date = new Date();
	try{ 
	    if (pool.getConnectionSize() == 0)
		{
			pool.initializePool();
		}	
		Connection con = null;
		Statement stmt = null;	
		con = pool.getConnection();
		stmt= con.createStatement();
	    ResultSet  rs=null;		
		String sqlString = "select code from user";
		rs =stmt.executeQuery(sqlString);
		String verifyusercode="";
		while(rs.next())
		{
	   String cCode = rs.getString("code");
		   if (verifyusercode=="")
		   {
		       verifyusercode = verifyusercode + cCode;
		   }
		   else
		   {
		       verifyusercode = verifyusercode + "," + cCode;
		   }
		}
	%>
	<center>
	<font size="5" face="隶书">用户注册</font><br><br>
	<form action="User_addext.jsp" method=POST onsubmit="return isok(this)">
	<input type="hidden" name="verify" value="<%=verifyusercode%>"> 
	<TABLE border=1 bordercolor=RoyalBlue bgcolor=LightBlue width=400>
	  <tr>
	    <TD width=100 align=center>用&nbsp;户&nbsp;名</TD>
		<TD width=300 align=left>
		 <input type="text" size="30" name="user_code"
       style="border-style: solid; border-width: 1">
		 <font color="red">(唯一)</font>
		</TD>
	  </tr>
	  <tr>
	    <TD width=100 align=center>姓&nbsp;&nbsp;&nbsp;&nbsp;名</TD>
		<TD width=300 align=left>
		 <input type="text" size="30" name="user_name"
     style="border-style: solid; border-width: 1">
		</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>密&nbsp;&nbsp;&nbsp;&nbsp;码</TD>
		<TD width=300 align=left>
		<input type="password" size="30" name="user_password"
    style="border-style: solid; border-width: 1">
		</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>密码确认</TD>
		<TD width=300 align=left>
		<input type="password" size="30" name="confirm_password" 
     style="border-style: solid; border-width: 1">
		</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>性&nbsp;&nbsp;&nbsp;&nbsp;别</TD>
		<TD width=300 align=left>
		<input type="radio" name="user_sex" value="m">男
		<input type="radio" name="user_sex" value="f">女
		</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>出年日期</TD>
		<TD width=300 align=left>
		 <input type="text" size="7" maxlength="4" name="user_year" 
      style="border-style: solid; border-width: 1">年
		 <select name="user_month" size="1">	
<%  for(int i=0; i<10;i++) { %>
			     <option value="0<%=i+1%>"><%=i+1%></option>
<% }  for (int i=10; i<12;i++){  	%>
			     <option value="<%=i+1%>"><%=i+1%></option>
<% } %>
	       </select>月
		   <select name="user_day" size="1">		 
<%   for (int j=1; j<10;j++){  %>
		     <option value="0<%=j%>"><%=j%></option>
<% } for (int j=10; j<32;j++)  {  %>
			     <option value="<%=j%>"><%=j%></option>
<% } %>
	       </select>日
	</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>职&nbsp;&nbsp;&nbsp;&nbsp;务</TD>
		<TD width=300 align=left>
		<input type="text" size="30" name="user_duty"
    style="border-style: solid; border-width: 1">
		</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>工作单位</TD>
		<TD width=300 align=left>
		<input type="text" size="40" name="user_workplace"
     style="border-style: solid; border-width: 1">
		</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>通信地址</TD>
		<TD width=300 align=left>
		<input type="text" size="40" name="user_address" style="border-style: solid; border-width: 1">
	</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>联系电话</TD>
		<TD width=300 align=left>
		<input type="text" size="40" name="user_tel"
     style="border-style: solid; border-width: 1">
		</TD>
	  </tr>
	  <tr>
		<TD width=100 align=center>邮件地址</TD>
	<TD width=300 align=left>
		<input type="text" size="40" name="user_email"
    style="border-style: solid; border-width: 1">
		</TD>
	  </tr>
	</TABLE>
	  <input type="submit" value="添  加">
	  <input type="reset" value="重  填">
	  <input type="button" onClick="onClick()" value="退  出">	
	 </form>
	</CENTER>
	<%
		if (rs != null) rs.close();
		pool.releaseConnection(con);
	}
	catch(Exception e)
	{
		System.out.println("Exception: " + e.getMessage());
	}
	%>
	</BODY>
	</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -