zhuce.jsp
<html>
<head>
<title>注册</title>
</head>
<body>
<form method="post" action="zhucecheck.jsp">
<table align="center" width=300>
<tr>
<td align="right">用户名:</td>
<td><input type="text" name="textUserName"></td>
</tr>
<tr>
<td align="right" >密码:</td>
<td ><input type="password" name="textPassword"></td>
</tr>
<tr>
<td align="right">性别:</td>
<td><input type="radio" name="R1" value="男" checked>男
<input type="radio" name="R1" value="女">女</td>
<tr>
<td align="right">电子邮箱:</td>
<td><input type="text" name="Email"><td>
</tr>
<tr>
<td colspan=2 align="center"><input type="submit" name="Submit" value="注册">
    <input type="reset" name="Reset" value="重置"></td>
</tr>
<table>
</body>
</html>
zhucecheck.jsp
<%@page language="java"%>
<%@page contentType="text/html;charset=GBK"%>
<%@page import ="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta http-equiv="Content-Type" content="zh-cn">
<title>注册</title>
</head>
<body><%
String driver="org.gjt.mm.mysql.Driver";
String url="jdbc:mysql://localhost:3306/liuyanban";
String user="root"; 
String password="shilin0328";
%>
<%!
Connection conn=null;
Statement stmt=null;%>
<%
  try
  {
  Class.forName(driver);
  }
  catch(Exception E)
  {
  out.println("无法加载程序:"+driver);
  E.printStackTrace();
  }
%>
  <div align="center"><font color="red"><strong>
<%
  request.setCharacterEncoding("GB2312");
  String strUserName=request.getParameter("textUserName");
  String strPassword=request.getParameter("textPassword") ;
  String strSex=request.getParameter("R1");
  String strEmail=request.getParameter("Email");
  out.println(""+strUserName);
  out.println(""+strPassword);
  out.println(""+strSex);
  out.println(""+strEmail);
  try
  {
    conn=DriverManager.getConnection(url,user,password);
    String sql="INSERT INTO liuyan(用户名,密码,性别,邮箱) VALUES('"+strUserName+"','"+strPassword+"','"+strSex+"','"+strEmail+"')";
stmt=conn.createStatement();
int i=stmt.executeUpdate(sql);
if(i==1)
    {
out.println("注册成功");
}
else
    {
out.println("注册失败");
}
  }
catch(SQLException SE)
{
  SE.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
 try
 {
  
  if(stmt!=null)
  {
    stmt.close();
conn.close();
  }
 }
 catch(SQLException E)
 {
   E.printStackTrace();
 }
}
%></strong></font></div>
</body>
</html>