这个应该是classpath的问题吧!
解决方案 »
- VMWare8出现这样的桌面
- 用struts2开发,如何分层
- 求高手:外网不能访问内网
- 请问这题目的正确答案为何?
- 对于SWING,APPLET的程序,有办法DEBUG吗??
- 大家好:小弟我有个Xml远程读取的问题?
- 为什么oracle to_char('未批准') as 项目状态 在JAVA类中取出的是乱码,在PL/SQL中是正确的
- java 怎样将String 转换成int
- 每一页的statment数目是不是有限?试了很多遍了,望和高手探讨。
- 这个问题很奇怪啊
- 请 问,jdbc如何实现与数据库连接:jdbc2与jdbc1有何不同,下面这段代码是不是jdbc1的
- 关于JSP中的内置session对象中属性的疑惑???
如果你的web-inf下面没有,自己建一个就行了
不行的话,再发帖
把user包放到这个目录下面
情况依旧
reg2.jsp
<%@ include file="data.jsp" %>
<%@ page import="java.until.data"
contentType="text/html;charset=gb2312"%>
<title>注册</title>
<%--link rel="stylesheet" href="shop.css" type="text/html"--%>
<%@ include file="top.jsp"%>
<div align="content">
<br>
<jsp:useBean id="check" class="check" scope="page"/>
<jsp:useBean id="setpass" class="user.setpass" scope="page"/>
<jsp:useBean id="mail" class="user.mail" scope="page"/>
<%
//获取表单内容
String user_name=request.getParameter("usename");
String pass=request.getParamenter("pass");
String repass=request.getParamenter("repass");
String question=request.getParamenter("question");
String answer=request.getParamenter("answer");
String true_name=request.getParamenter("name");
String id_card=request.getParamenter("idcard");
String birth_y=request.getParamenter("birth_y");
String birth_m=request.getParamenter("brith_m");
String birth_d=request.getParamenter("birth_d");
String email=request.getParamenter("email");
String homepage=request.getParamenter("homepage");
String tel=request.getParamenter("tel");
String mobile=request.getParamenter("mobile");
String bp=request.getParamenter("bp");
String address=request.getParamenter("address");
String post_zip=request.getParamenter("zip");
String province=request.getParamenter("province");
String education=request.getParamenter("education");
String employment=request.getParamenter("employment");
String occupation=request.getParamenter("occupation");
String company=request.getParamenter("company");
//String intro=request.getParamenter("intro");
//String face=request.getParamenter("face");
int user_level=1
//调用java bean中的方法对密码进行加密
String[] password=setpass.setpass(pass)
String pass_word=password[0]
String temp_word=password[1]//使用 java bean中的方法检查数据的合法性
if(!check.check_user(user_name))
out.print("<font color=red>用户名填写错误!</font>--用户名只能是字母,数字和\"_\",长度为3~20<br>");
if(!check.check_have(user_name))
out.print("<font color=red>用户名已经存在!</font><br>");
else if(!check.check_pass(pass,repass))
out.print("<font color=red>密码填写错误!</font>--密码不能为空,长度为3~20
两次密码填写一致<br>");
else if(!check.check_blank(question))
out.print("<font color=red>密码提示问题不能为空!</font><br>");
else if(!check.check_blank(answer))
out.print("<font color=red>密码!提示问题不能为空</font><br>");
else if(!check.check_blank(true_name))
out.print("<font color=red>真是姓名不能为空</font><br>");
else if(!check.check_idcard(id_card))
out.print("<font color=red>省份证填写不对</font>--请填写15位或18位<br>");
else if(!check.check_email(email))
out.print("<font color=red>电子邮件填写不对</font><br>");
else if(!check.check_blank(address))
out.print("<font color=red>请填写你的邮寄地址!</font>--我们将按这个地址给你邮寄商品<br>");
else if(!check.check_postzip(post_zip))
out.print("<font color=red>邮政编码填写不对</font><br>");
else
{ //将数据写如数据库
String sql="insert into user_info
(nick_name,pass_word,true_name,id_card,pass_question,pass_anser,birth_y,birth_m,birth_d,email,homepage,tel,mobile,bp,address,post_zip,province,education,employment,occupation,company,face,intro,temp_word)
values('"+user_name+"','"+pass_word+"','"+ture_name+"','"+id_card+"','"+question+"','"+answer+"','"+birth_y+"','"+birth_m+"',"+birth_d+"','"+email+"','"+homepage+"','"+tel+"','"+mobile+"'.'"+bp+"','"+address+"','"+post_zip+"','"+province+"','"education"','"+employment+"','"+occupation+"','"+company+"','"+face+"','"+intro+"','"+temp_word+"')";
try{//扑捉异常
stmt.executeupdate(sql);
out.print("用户注册成功");
catch(SQLException e)
(out.print(e);}
//给用户送确认信件
String message="亲爱的"+user_name+":\n你在DSY超市注册成功\n你的帐号是:"user_name+"密码是:"+pass+"\n为了你的帐号安全,请牢记你的帐号号密码,然后将着封信删除!\n\n\nDSY超市 196.168.1.1";
}
Stmt.close();
Conn.close();
%>
</div>
<%@ include file="tail.jsp"%>
check.java
package user;
import java.sql.*;
public class check
{boolean right=true;
//检查是否数据为空
public boolean check_blank (String string){
boolean blank=true;
if (string==null||string.trim().compareTo("")==0)
blank=false;
return blank;
}
//检查模个字符是否位合法字符
public boolean check_have(String[] words,String temp)
{
boolean have=true,have_tmp=false;
int I,J;
for(I=0;I<temp.length();I++)
{ String t=temp.substring(I,I+1);
for(J=0;J<words.length;J++)
{ have_tmp=false;
if(words[J].equals(t)){
have_tmp=true;
break;}
}
if(!have_tmp){
have=false;
break;
}
}
return have;
}
//检查字符串中是非包含模个字符
public boolean check_str_char(String str,String tag)
{boolean have_tag=false;
int I;
for(I=0;I<str.length();I++){
if (str.substring(I,I+1).equals(tag))
have_tag=true;
}
return have_tag;
}//检查用户名是否合法
public boolean check_user(String str)
{
String[] word={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9","_"};
if(str==null||str.trim().length()<3||str.trim().length()>20)
right=false;
else{
if (!check_have(word,str)){
right=false;
}
}
return right;
}
//检查密码是否合法
public boolean check_pass(String pass,String repass)
{
if (pass==null||pass.trim().length()<5||pass.trim().length()>20)
right=false;
else if (!pass.trim().equals(repass))
right=false;
return right;
}
//检查E_MAIL地址的合法性
public boolean check_email(String email){
if (!check_str_char(email,"@")||!check_str_char(email,"."))
right=false;
return right;
}
//检查邮编合法性
public boolean check_postzip(String postzip){
String[] post={"0","1","2","3","4","5","6","7","8","9"};
if (postzip==null||postzip.trim().length()!=6)
right=false;
else if (!check_have(post,postzip.trim()))
right=false;
return right;
}//检查身份证号码合法性
public boolean check_idcard(String idcard)
{ String[] id_card={"0","1","2","3","4","5","6","7","8","9"};
if(idcard==null||(idcard.trim().length()!=15 && idcard.trim().length()!=18))
right=false;
else if (!check_have(id_card,idcard.trim()))
right=false;
return right;
}//检查用户已注册否
public boolean check_user_have(String user){
java.sql.Connection Conn;
java.sql.Statement Stmt;
java.sql.ResultSet Rst;
try{
Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
}
catch(java.lang.ClassNotFoundException e){
System.out.println(e);
}
try{
Conn=DriverManager.getConnection("jdbc.odbc:shop","Adminstrator","duanshuy");
Stmt=Conn.createStatement();
Rst=Stmt.executeQuery("select( from user_info where nick_name='"+user+"'");
if(Rst.next())
right=false;
Rst.close();
Stmt.close();
Conn.close();
}
catch(SQLException ex){
System.out.println(ex);}
return right;
}}
package user;