跟踪程序,是不是发生SQLException异常了?
解决方案 »
- hibernate @注解怎么实现三个实现之间的关联??
- 如何获取请求用户的内网IP
- 关于jtds连接数据库问题~~~
- 在JSP中怎么用JS实现树形菜单
- 在北京,哪的软件开发培训好,请先辈指教,在线哭等!!!(偶工科大专,35了,没有多少编程经验)
- JBuilder9如何集成Struts 1.2.8?
- 为什么很多时候java程序,需要在command窗口中按一下键 才会继续往下执行
- 使用Enterprise JavaBeans,可以轻松地在JSP开发的Web中实现事务、安全、会话等等企业级应用所需要的功能。
- 高分求教,此作业如何下手?谢谢
- 哪儿可以找到可用于SQL SERVER的专业级的数据库连接池 50分相送!
- 刚学java,碰到一大堆新名词,请指教一下,多谢!
- Velocity macro指令第二个参数怎么不显示呢?
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*,java.io.*;" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户注册</title>
<style type="text/css">
<!--
@import url("total.css");
.STYLE1 {color: #FF0000}
-->
</style></head><body>
<form name="RegisterForm" method="post" action="regist.do">
<div align="center">
<table width="100%" bgColor=#fef7e3> <tr>
<td width="433"><div align="right">用户名<span class="STYLE1">*</span></div></td>
<td width="494"><label>
<div align="left">
<input name="username" type="text" size="20" maxlength="20">
</div>
</label></td>
</tr>
<tr>
<td width="433"><div align="right">密码<span class="STYLE1">*</span></div></td>
<td><div align="left">
<input name="userpsw" type="password" size="20" maxlength="20">
</div></td>
</tr>
<tr>
<td width="433"><div align="right">确认密码<span class="STYLE1">*</span></div></td>
<td><div align="left">
<input name="reuserpsw" type="password" size="20" maxlength="20">
</div></td>
</tr>
<tr>
<td width="433"><div align="right">电子邮件<span class="STYLE1">*</span></div></td>
<td><div align="left">
<input name="useremail" type="text" size="20" maxlength="50">
</div></td>
</tr> </table>
<input type="submit" name="Submit" value="注册">
<input name="Submit2" type="reset" value="重置">
</div>
</form>
</body>
</html>
/**********************************************************
************************************************************
*************************************************************************/
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.4/xslt/JavaClass.xslpackage footman;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.ServletContext;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
import java.sql.Connection;
/**
* MyEclipse Struts
* Creation date: 12-06-2005
*
* XDoclet definition:
* @struts:action path="/regist" name="RegisterForm" scope="request" validate="true"
* @struts:action-forward name="index.jsp" path="/index.jsp"
*/
public class RegisterAction extends Action { // --------------------------------------------------------- Instance Variables // --------------------------------------------------------- Methods /**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
RegisterForm RegisterForm = (RegisterForm) form;
//??????
RegisterForm registerform = (RegisterForm)form;
String username = registerform.getUsername();
String userpsw = registerform.getUserpsw();
String useremail = registerform.getUseremail();
System.out.println("1");
System.out.println(userpsw);
System.out.println(useremail);
//???????
ServletContext context = servlet.getServletContext();
DataSource datasource = (DataSource)context.getAttribute("mysqlds");
String sql = "insert into users(username,userpsw,useremail) values('" + username+ "','" + userpsw+ "','" + useremail+ "')";
try{
Connection conn = datasource.getConnection();
Statement stmt = conn.createStatement();
int i = stmt.executeUpdate(sql);
stmt.close();
conn.close();
if(i == 1){
return (mapping.findForward("success"));
}
}catch(SQLException e){
e.printStackTrace();
}
return (mapping.findForward("failed"));
}}
/************************************************************************/
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.4/xslt/JavaClass.xslpackage footman;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;/**
* MyEclipse Struts
* Creation date: 12-06-2005
*
* XDoclet definition:
* @struts:form name="RegisterForm"
*/
public class RegisterForm extends ActionForm { // --------------------------------------------------------- Instance Variables
private String username = null;
private String userpsw = null;
private String reuserpsw = null;
private String useremail = null;
// --------------------------------------------------------- Methods
public void setUsername(String username){
this.username = username;
}
public void setUserpsw(String userpsw){
this.userpsw = userpsw;
}
public void setReuserpsw(String reuserpsw){
this.reuserpsw = reuserpsw;
}
public void setUseremail(String useremail){
this.useremail = useremail;
}
public String getUsername(){
return this.username;
}
public String getUserpsw(){
return this.userpsw;
}
public String getReuserpsw(){
return this.reuserpsw;
}
public String getUseremail(){
return this.useremail;
}
}