JavaBean:用于判断用户名是否存在,邮箱格式是否正确
package Bean;
import ;
import ;
import ;
import ;
import ;
import ;
public class TongXun {
public TongXun() {
}
// 检查用户名是否存在
public boolean check(String mynm) throws SQLException,
UnsupportedEncodingException {
String mynm1 = ();
byte a[] = ("GBK");
String mynm3 = new String(a);
mynm = new String(a);
Connection con = null;
Statement sql = null;
ResultSet rs = null;
try {
("");
} catch (ClassNotFoundException event) {
();
}
con = ("jdbc:odbc:tongXun", "", "");
sql = ();
rs = ("SELECT * FROM customers WHERE name" + "=" + "'"
+ mynm3 + "'");
if (()) {
return true;
} else {
return false;
}
}
public boolean emailCheck(String email) {
if (("@") == -1 || (".") == -1)
return false;
return true;
}
}
Servlet:实现添加页面和显示新数据页面之间跳转,并可判断添加的时候邮箱格式是否正确
;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
public class Direct extends HttpServlet {
/**
* Constructor of the object.
*/
public Direct() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* ***@param request
*
jsp个人通讯录系统源代码 来自淘豆网m.daumloan.com转载请标明出处.