package com.yourcompany.struts.action;import java.sql.SQLException;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 com.yourcompany.struts.form.SignForm;
import com.yourcompany.struts.service.RegistLogic;public class SignAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws SQLException {

SignForm signForm = (SignForm) form;
String PageForward = "wrong";
RegistLogic registLogic = new RegistLogic(this.getDataSource(request));
int i = 1;
if(i == registLogic.checkRegist(signForm))
{
System.out.println(PageForward);

PageForward = "login";

System.out.println(PageForward);
}

return mapping.findForward(PageForward);
}
}
package com.yourcompany.struts.service;
import java.sql.SQLException;
import javax.sql.DataSource;
import com.yourcompany.struts.form.SignForm;
import com.yourcompany.struts.ado.DataBase;
public class RegistLogic 
{
private DataSource dc;
public RegistLogic(DataSource dc)
{
this.dc = dc;
}
public int checkRegist(SignForm signForm) throws SQLException
{
DataBase db = new DataBase(this.dc);
int flag;
StringBuffer bfSql = new StringBuffer();
bfSql.append("INSERT INTO bbsuser(username,password,nickname,sex,birthyear,birthmonth,birthday,e_mail,mobile,signature)values(");
bfSql.append("'");
bfSql.append(signForm.getUsername());
bfSql.append("','");
bfSql.append(signForm.getPassword());
bfSql.append("','");
bfSql.append(signForm.getNickname());
bfSql.append("','");
bfSql.append(signForm.getSex());
bfSql.append("','");
bfSql.append(signForm.getBirthyear());
bfSql.append("','");
bfSql.append(signForm.getBirthmonth());
bfSql.append("','");
bfSql.append(signForm.getBirthday());
bfSql.append("','");
bfSql.append(signForm.getEmail());
bfSql.append("','");
bfSql.append(signForm.getMobile());
bfSql.append("','");
bfSql.append(signForm.getSigniture());
bfSql.append("')");
flag = db.upTable(bfSql.toString());
return flag;
}
}
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.yourcompany.struts.form;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: 11-29-2006
 * 
 * XDoclet definition:
 * @struts.form name="signForm"
 */
public class SignForm extends ActionForm {
/*
 * Generated Methods
 */
private String username;
private String password;
private String password2;
private String nickname;
private String sex;
private String birthyear;
private String birthmonth;
private String birthday;
private String email;
private String mobile;
private String signiture;

public String getBirthday() {
return birthday;
} public void setBirthday(String birthday) {
this.birthday = birthday;
} public String getBirthmonth() {
return birthmonth;
} public void setBirthmonth(String birthmonth) {
this.birthmonth = birthmonth;
} public String getBirthyear() {
return birthyear;
} public void setBirthyear(String birthyear) {
this.birthyear = birthyear;
} public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} public String getMobile() {
return mobile;
} public void setMobile(String mobile) {
this.mobile = mobile;
} public String getNickname() {
return nickname;
} public void setNickname(String nickname) {
this.nickname = nickname;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public String getPassword2() {
return password2;
} public void setPassword2(String password2) {
this.password2 = password2;
} public String getSex() {
return sex;
} public void setSex(String sex) {
this.sex = sex;
} public String getSigniture() {
return signiture;
} public void setSigniture(String signiture) {
this.signiture = signiture;
} public String getUsername() {
return username;
} public void setUsername(String username) {
this.username = username;
} /** 
 * Method validate
 * @param mapping
 * @param request
 * @return ActionErrors
 */
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
} /** 
 * Method reset
 * @param mapping
 * @param request
 */
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
}