htm文件 register.htm***************<%@ page contentType="text/html;charset=GBK" %>
<html>
<head>
<title>用户注册</title>
</head>
<body bgcolor="#DFEAFF"><form method="POST" action="register.jsp">
<table border="1" width="100%" height="407">
<tr>
<td width="34%" height="16" align="right">登陆名</td>
<td width="66%" height="16"><input type="text" name="name" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">密码</td>
<td width="66%" height="16"><input type="text" name="password" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">真实姓名</td>
<td width="66%" height="16"><input type="text" name="username" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">性别</td>
<td width="66%" height="16"><input type="radio" value="男" checked name="gender">男<input type="radio" name="gender" value="女">女</td>
</tr>
<tr>
<td width="34%" height="16" align="right">学历</td>
<td width="66%" height="16"><input type="text" name="education" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">Email</td>
<td width="66%" height="16"><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">简历</td>
<td width="66%" height="16"></td>
</tr>
<tr>
<td width="34%" height="203"></td>
<td width="66%" height="203"><textarea rows="10" name="resume" cols="75"></textarea></td>
</tr>
</table>
<p align="center"><input type="submit" value="提交" name="submit"><input type="reset" value="重写" name="reset"></p>
</form></body>
</html>
<html>
<head>
<title>用户注册</title>
</head>
<body bgcolor="#DFEAFF"><form method="POST" action="register.jsp">
<table border="1" width="100%" height="407">
<tr>
<td width="34%" height="16" align="right">登陆名</td>
<td width="66%" height="16"><input type="text" name="name" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">密码</td>
<td width="66%" height="16"><input type="text" name="password" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">真实姓名</td>
<td width="66%" height="16"><input type="text" name="username" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">性别</td>
<td width="66%" height="16"><input type="radio" value="男" checked name="gender">男<input type="radio" name="gender" value="女">女</td>
</tr>
<tr>
<td width="34%" height="16" align="right">学历</td>
<td width="66%" height="16"><input type="text" name="education" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">Email</td>
<td width="66%" height="16"><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="34%" height="16" align="right">简历</td>
<td width="66%" height="16"></td>
</tr>
<tr>
<td width="34%" height="203"></td>
<td width="66%" height="203"><textarea rows="10" name="resume" cols="75"></textarea></td>
</tr>
</table>
<p align="center"><input type="submit" value="提交" name="submit"><input type="reset" value="重写" name="reset"></p>
</form></body>
</html>
解决方案 »
- 在SSH框架上再集成CXF,启动时出现的InvocationTargetException、IllegalArgumentException异常,大家帮忙看看
- 1G多的word文档存到数据库中,并通过jsp页面显示
- 关于短信下发时,如果客户连续点击三次,给予提示问题的探讨
- 关于spring的问题
- javascript判断提交的表单
- Java 多个文件上传 如何暂停,再续传
- 如何有pojo生成相应的hbm 配置文件,能用myeclipse吗
- 请问jsp中 redirect 与forword 有什么不同?
- 怎么上传多个文件?
- 为什么动态生成的图片,JSP不能动态的获得
- ■■网页中读取外部word文件作为页面显示内容应当怎么做呢?高分请教!■■
- 能不能写一段JDBC调用SQL SERVER的代码
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="registerBean" scope="page" class="login.login" />
<%
String name = request.getParameter("name");
String password = request.getParameter("password");
String username = request.getParameter("username");
String gender = request.getParameter("gender");
String education = request.getParameter("education");
String email = request.getParameter("email");
String resume = request.getParameter("resume");
if ((name==null)||(password==null))
{
%><body bgcolor="#DFEAFF"> <p>用户名和密码不能为空 </p>
<input type="button" value="return" onclick="history.back()">
<%
}
else
{
String sql = "select * from login where name = '" + name + "'";
ResultSet rs = registerBean.executeQuery(sql);
if(rs.next())
{
rs.close();
session.putValue("register_message","duplicate name found!");
%>
<script language=Javascript>
window.location="info.jsp?str=<%=name%>is exist"
</script>
<% }
else
{ rs.close();
%>
<form method="POST" action="register2.jsp">
<p><input type="text" name="name" size="20" value="<%=name%>"><br>
<input type="text" name="name" size="20" value="<%=password%>"><br>
<input type="text" name="name" size="20" value="<%=username%>"> <br>
<input type="text" name="name" size="20" value="<%=email%>"> <br>
<input type="text" name="name" size="20" value="<%=gender%>"> <br>
<input type="text" name="name" size="20" value="<%=education%>"> <br>
<input type="text" name="name" size="20" value="<%=resume%>">
<p><font color="#0000FF"> <br>
请检查您的注册信息:</font></p>
<table border="1" width="60%">
<tr>
<td width="50%">登陆名</td>
<td width="50%"> <%=name%> </td>
</tr>
<tr>
<td width="50%">密码</td>
<td width="50%"> <%=password%> </td>
</tr>
<tr>
<td width="50%">用户名</td>
<td width="50%"> <%=username%> </td>
</tr>
<tr>
<td width="50%">邮件</td>
<td width="50%"> <%=email%> </td>
</tr>
<tr>
<td width="50%">性别</td>
<td width="50%"> <%=gender%> </td>
</tr>
<tr>
<td width="50%">学历</td>
<td width="50%"><%=education%> </td>
</tr>
<tr>
<td width="50%">简历</td>
<td width="50%"> <%=resume%> </td>
</tr>
</table>
<p> </p>
<p><input type="submit" value="提交" name="B1"> <input type="reset" value="全部重写" name="B2" onclick="history.back()"></p>
</form>
<% }
}
%>
*************<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="registerBean2" scope="page" class="login.login" />
<%//I
String name = request.getParameter("name");
String password= request.getParameter("password");
String username= request.getParameter("username");
String gender= request.getParameter("gender");
String education= request.getParameter("education");
String email= request.getParameter("email");
String resume= request.getParameter("resume");
String sql = "insert into login(name,password,email,education,gender,resume)values('" + name +"','" + password+"','" +email +"','"+gender +"','" + resume +"')";
registerBean2.executeQuery(sql);
session.putValue("name",name);
%>
<body>
<script language=javascript>
window.location="info.jsp?str=注册成功"
</script>
</body>
所有对数据库的更改,包括update,insert都需要stmt.executeUpdate(sql)来执行,再写个方法吧!
package DBBean;/**
* Title: 数据库连接Bean
* Description:
* Copyright: Copyright (c) 2002
* Company:
* @author hover YY
* @version 1.0
*/import java.sql.*;
import java.util.*;
public class datacon
{
String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String ConnStr = "jdbc:odbc:dzxj";
String UserName = "sa";
String UserPassword = "";
Connection conn = null;
Statement stmt=null;
ResultSet rs = null;
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd");
public datacon()
{
try {
Class.forName(DBDriver);
}catch(java.lang.ClassNotFoundException e)
{
System.err.println("数据库驱动程序加载错误:" + e.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
rs = null;
try{
conn = DriverManager.getConnection(ConnStr,UserName,UserPassword);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
}catch(SQLException ex){
System.err.println("数据库检索错误: " + ex.getMessage());
}
return rs;
}
public boolean executeUpdate(String sql)
{
boolean bupdate=false;
rs = null;
try {
conn = DriverManager.getConnection(ConnStr,UserName,UserPassword);
Statement stmt = conn.createStatement();
int rowCount = stmt.executeUpdate(sql);
if(rowCount!=0)bupdate=true;
}
catch(SQLException ex)
{
System.err.println("数据库更新出错:" + sql +"\n"+ ex.getMessage());
}
return bupdate;
}
public ResultSet getResult()
{
rs = null;
try{
conn = DriverManager.getConnection(ConnStr,UserName,UserPassword);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery("select C_name,C_sum from info_grade order by ID asc");
}catch(SQLException ex){
System.err.println("数据库检索错误: " + ex.getMessage());
}
return rs;
}
public boolean connclose()
{
try
{
if(stmt!=null)
stmt.close();
if(conn!=null)
conn.close();
return true;
}catch(SQLException ex)
{
System.err.println("数据库断开时出错:"+ex.getMessage());
return false;
}
}
public Connection getConn()
{
try
{
return DriverManager.getConnection(ConnStr,UserName,UserPassword);
}catch(SQLException ex)
{
return null;
}
}
public String GetFormatDate(String formatd)
{
try
{
return formatter.format(formatter.parse(formatd));
}catch(java.text.ParseException ex)
{
return "no";
}
}
public String GetFormatDate(java.util.Date formatd)
{
return formatter.format(formatd);
}
}