データベース_jdbc_改造MVCケース(登録)
54910 ワード
概要:データベースアプリケーションの改造(以前はxmlだったがmysql)1.データベースドライバをインポート2.アプリケーションに対応するライブラリとテーブル3を作成します.改造ダオ
4.サービス5を改造する.工場モデルを使用すると、下位層が変わっても、ビジネス層の1行のコードを変更する必要はありません.
(DaoFactoryは、DaoImplを生成するためにプロファイルを読み込むインスタンスであるため)
使用するサードパーティjarパッケージ
UserDaoはdaoパッケージにあります
CopyOfUserDaoJdbcImplはdaoに位置する.implパッケージ
UserDaoJdbcImplはdにあります
ao.implパッケージ
UserDaoXmlImplはdにあります
ao.implパッケージ
Userはdomainにあります
パッケージ
DaoExceptionはexceptionにあります
パッケージ
UserExistExceptionはexceptionにあります
パッケージ
DaoFactoryはfactoryにあります
パッケージ
BusinessServiceImplはサービスにあります.impl
パッケージ
JdbcUtilsはutilsにある
パッケージ
ServiceUtilsはutilsパッケージにあります
WebUtilsはutilsパッケージにあります
XmlUtilsはutilsパッケージにあります
ImageServiceletはwebにあります.コントロールパッケージ
LoginServeretはwebにあります.コントロールパッケージ
LogoutServeretはwebにあります.コントロールパッケージ
RegisterServiceletはwebにあります.コントロールパッケージ
RegisterFormはwebにあります.formbeanパッケージ
LoginUIservletはwebにあります.UIパッケージ
RegisterUIservletはwebにあります.UIパッケージ
dao.propertiesはsrcクラスディレクトリの下にあります
db.propertiesはsrcクラスディレクトリの下にあります
Users.xmlはsrcクラスディレクトリの下にあります
index.jspはWebRootディレクトリの下にあります
message.jspはWebRootディレクトリの下にあります
ShowCalendar.jsはWebRoot/jsディレクトリの下にあります(WEB-INFに置かないでください)
login.jspはWebRoot/WEB-INF/JSPディレクトリの下にあります
register.jspはWebRoot/WEB-INF/JSPディレクトリの下にあります
4.サービス5を改造する.工場モデルを使用すると、下位層が変わっても、ビジネス層の1行のコードを変更する必要はありません.
(DaoFactoryは、DaoImplを生成するためにプロファイルを読み込むインスタンスであるため)
使用するサードパーティjarパッケージ
jaxen-1.1-beta-6.jar
jstl.jar
standard.jar
dom4j-1.6.1.jar
commons-beanutils-1.8.0.jar
commons-logging.jar
MySQL :mysql-connector-java-5.0.8-bin.jar
UserDaoはdaoパッケージにあります
package cn.itcast.dao;
import cn.itcast.domain.User;
public interface UserDao {
// 1,
void add(User user);
// 2, , ,
User find(String username, String password);
// 3, , ,
boolean find(String username);
}
CopyOfUserDaoJdbcImplはdaoに位置する.implパッケージ
package cn.itcast.dao.impl;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import cn.itcast.dao.UserDao;
import cn.itcast.domain.User;
import cn.itcast.exception.DaoException;
import cn.itcast.utils.JdbcUtils;
/*
1.
2.
3. dao
<user id="8881" username="weixi" password="888" email="[email protected]" birthday="1990-09-09" nickname=" "/>
mysql -uroot -proot
set character_set_client=gb2312;
set character_set_results=gb2312;
create database day14_user;
use day14_user;
create table users
(
id varchar(40) primary key,
username varchar(40) not null unique,
password varchar(40) not null,
email varchar(100) not null unique,
birthday date,
nickname varchar(40) not null
);
show tables;
*/
public class CopyOfUserDaoJdbcImpl implements UserDao {
// 1,
public void add(User user){
Connection conn=null;
Statement st=null;
ResultSet rs=null;
try {
conn=JdbcUtils.getConnection();
st=conn.createStatement();//preparedStatement
String id=user.getId();
String username=user.getUsername();
String password=user.getPassword();
String email=user.getEmail();
String birthday=user.getBirthday().toLocaleString();
String nickname=user.getNickname();
String sql="insert into users(id,username,password,email,birthday,nickname) values('"+id+"','"+username+"','"+password+"','"+email+"','"+birthday+"','"+nickname+"')";
int num=st.executeUpdate(sql);
// , ,
if (num<1) {
throw new RuntimeException(" ");
}
} catch (Exception e) {
// , ,
// , DaoException( , )
throw new DaoException(e);
}finally{
JdbcUtils.release(conn, st, rs);
}
}
//'or 1=1 or username='
//select * from users where username=''or 1=1 or username='' and password=''
// 2, , ,
public User find(String username,String password){
Connection conn=null;
Statement st=null;
ResultSet rs=null;
try {
conn=JdbcUtils.getConnection();
st=conn.createStatement();//preparedStatement
String sql="select * from users where username='"+username+"' and password='"+password+"'";
rs=st.executeQuery(sql);
if (rs.next()) {
// user user
User user=new User();
user.setId(rs.getString("id"));
user.setUsername(username);
user.setPassword(password);
user.setEmail(rs.getString("email"));
user.setBirthday(rs.getDate("birthday"));
user.setNickname(rs.getString("nickname"));
return user;
}
//
return null;
} catch (Exception e) {
// , ,
// , DaoException( , )
throw new DaoException(e);
}finally{
JdbcUtils.release(conn, st, rs);
}
}
// 3, , ,
public boolean find(String username){
Connection conn=null;
Statement st=null;
ResultSet rs=null;
try {
conn=JdbcUtils.getConnection();
st=conn.createStatement();//preparedStatement
String sql="select * from users where username='"+username+"'";
rs=st.executeQuery(sql);
if (rs.next()) {
return true;
}
return false;
} catch (Exception e) {
// , ,
// , DaoException( , )
throw new DaoException(e);
}finally{
JdbcUtils.release(conn, st, rs);
}
}
}
/*
select * from users where username=''or 1=1 or username='' and
password=''
mysql -uroot -proot
set character_set_client=gb2312;
set character_set_results=gb2312;
use day14_user;
select * from users where username='' or 1=1 and password=''
select * from users where username='' or 1=1 or username='' and
password=''
SQL :' or 1=1 or username='
*/
UserDaoJdbcImplはdにあります
ao.implパッケージ
package cn.itcast.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import cn.itcast.dao.UserDao;
import cn.itcast.domain.User;
import cn.itcast.exception.DaoException;
import cn.itcast.utils.JdbcUtils;
/*
1.
2.
3. dao
<user id="8881" username="weixi" password="888" email="[email protected]" birthday="1990-09-09" nickname=" "/>
mysql -uroot -proot
set character_set_client=gb2312;
set character_set_results=gb2312;
create database day14_user;
use day14_user;
create table users
(
id varchar(40) primary key,
username varchar(40) not null unique,
password varchar(40) not null,
email varchar(100) not null unique,
birthday date,
nickname varchar(40) not null
);
show tables;*/
/*statment preparedStatement :
1. preparedStatement statement
2. preparedStatement sql
3. preparedStatement sql ,
java---class---jvm
sql---- --- */
public class UserDaoJdbcImpl implements UserDao {
// 1,
public void add(User user){
Connection conn=null;
PreparedStatement st=null;
ResultSet rs=null;
try {
conn=JdbcUtils.getConnection();
// String sql, PreparedStatement
String id=user.getId();
String username=user.getUsername();
String password=user.getPassword();
String email=user.getEmail();
java.util.Date birthday=user.getBirthday();
String nickname=user.getNickname();
String sql="insert into users(id,username,password,email,birthday,nickname) values(?,?,?,?,?,?)";
st=conn.prepareStatement(sql);//preparedStatement
//
st.setString(1, id);
st.setString(2, username);
st.setString(3, password);
st.setString(4, email);
// util.Date Long, sql.Date
st.setDate(5, new java.sql.Date(birthday.getTime()));
st.setString(6, nickname);
// , !
int num=st.executeUpdate();
// , ,
if (num<1) {
throw new RuntimeException(" ");
}
} catch (Exception e) {
// , ,
// , DaoException( , )
throw new DaoException(e);
}finally{
JdbcUtils.release(conn, st, rs);
}
}
//'or 1=1 or username='
//select * from users where username=''or 1=1 or username='' and password=''
// 2, , ,
public User find(String username,String password){
Connection conn=null;
PreparedStatement st=null;
ResultSet rs=null;
try {
conn=JdbcUtils.getConnection();
String sql="select * from users where username=? and password=?";
st=conn.prepareStatement(sql);//preparedStatement
// !
st.setString(1, username);
st.setString(2, password);
// PreparedStatement , !
rs=st.executeQuery();
if (rs.next()) {
// user user
User user=new User();
user.setId(rs.getString("id"));
user.setUsername(username);
user.setPassword(password);
user.setEmail(rs.getString("email"));
user.setBirthday(rs.getDate("birthday"));
user.setNickname(rs.getString("nickname"));
return user;
}
//
return null;
} catch (Exception e) {
// , ,
// , DaoException( , )
throw new DaoException(e);
}finally{
JdbcUtils.release(conn, st, rs);
}
}
// 3, , ,
public boolean find(String username){
Connection conn=null;
PreparedStatement st=null;
ResultSet rs=null;
try {
conn=JdbcUtils.getConnection();
String sql="select * from users where username=?";
st=conn.prepareStatement(sql);//preparedStatement
// !
st.setString(1, username);
// PreparedStatement , !
rs=st.executeQuery();
if (rs.next()) {
return true;
}
return false;
} catch (Exception e) {
// , ,
// , DaoException( , )
throw new DaoException(e);
}finally{
JdbcUtils.release(conn, st, rs);
}
}
}
/*
select * from users where username=''or 1=1 or username='' and
password=''
mysql -uroot -proot
set character_set_client=gb2312;
set character_set_results=gb2312;
use day14_user;
select * from users where username='' or 1=1 and password=''
select * from users where username='' or 1=1 or username='' and
password=''
SQL :' or 1=1 or username='
*/
UserDaoXmlImplはdにあります
ao.implパッケージ
package cn.itcast.dao.impl;
import java.io.IOException;
import java.text.SimpleDateFormat;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import cn.itcast.dao.UserDao;
import cn.itcast.domain.User;
import cn.itcast.utils.XmlUtils;
public class UserDaoXmlImpl implements UserDao {
// 1,
public void add(User user){
try {
Document doc= XmlUtils.getDocument();
Element root=doc.getRootElement();
Element user_tag=root.addElement("user");
user_tag.setAttributeValue("id", user.getId());
user_tag.setAttributeValue("username", user.getUsername());
user_tag.setAttributeValue("password", user.getPassword());
user_tag.setAttributeValue("email", user.getEmail());
user_tag.setAttributeValue("birthday", user.getBirthday()==null?"":user.getBirthday().toLocaleString());
user_tag.setAttributeValue("nickname", user.getNickname());
XmlUtils.write2Xml(doc);
} catch (Exception e) {
// , ,
throw new RuntimeException(e);
}
}
// 2, , ,
public User find(String username,String password){
try {
Document doc= XmlUtils.getDocument();
Element e= (Element) doc.selectSingleNode("//user[@username='"+username+"' and @password='"+password+"']");
if (e==null) {
return null;
}
// , xml User
User user=new User();
user.setId(e.attributeValue("id"));
user.setUsername(e.attributeValue("username"));
user.setPassword(e.attributeValue("password"));
user.setEmail(e.attributeValue("email"));
user.setNickname(e.attributeValue("nickname"));
// ,
String date=e.attributeValue("birthday");
if (date==null || "".equals(date)) {
user.setBirthday(null);
} else {
// ,
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
user.setBirthday(df.parse(date));
}
return user;
} catch (Exception e) {
// , ,
throw new RuntimeException(e);
}
}
// 3, , ,
public boolean find(String username){
try {
Document doc= XmlUtils.getDocument();
Element e= (Element) doc.selectSingleNode("//user[@username='"+username+"']");
if (e==null) {
return false;
}
return true;
} catch (Exception e) {
// , ,
throw new RuntimeException(e);
}
}
}
Userはdomainにあります
パッケージ
package cn.itcast.domain;
import java.util.Date;
public class User {
private String id;
private String username;
private String password;
private String email;
private Date birthday;
private String nickname;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
}
DaoExceptionはexceptionにあります
パッケージ
package cn.itcast.exception;
public class DaoException extends RuntimeException {
// Dao , !
// , RuntimeException, !
public DaoException() {
}
public DaoException(String message) {
super(message);
}
public DaoException(Throwable cause) {
super(cause);
}
public DaoException(String message, Throwable cause) {
super(message, cause);
}
public DaoException(String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
UserExistExceptionはexceptionにあります
パッケージ
package cn.itcast.exception;
public class UserExistException extends Exception {
// Exception , !
public UserExistException() {
}
public UserExistException(String message) {
super(message);
}
public UserExistException(Throwable cause) {
super(cause);
}
public UserExistException(String message, Throwable cause) {
super(message, cause);
}
public UserExistException(String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
DaoFactoryはfactoryにあります
パッケージ
package cn.itcast.factory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class DaoFactory {
/*23 !
* 1,
* 2, src dao.properties
* 3, , !*/
private static Properties pro=new Properties();
// 1 , ,
private DaoFactory(){
//dao.properties 1
String pro_name="dao.properties";
InputStream in=DaoFactory.class.getClassLoader().getResourceAsStream(pro_name);
try {
pro.load(in);
} catch (IOException e) {
//
throw new RuntimeException(e);
}
}
// 2 ,
private static DaoFactory instance=new DaoFactory();
// 3 ,
public static DaoFactory getInstance(){
return instance;
}
// ! ! ( ), !
public <T> T createDao(Class<T> clazz){
// UserDao=cn.itcast.dao.impl.UserDaoJdbcImpl
//String full_name=clazz.getName();//cn.itcast.dao.UserDao
String simple_name=clazz.getSimpleName();//UserDao
//simple_name dao.properties , impl_name
String impl_name=pro.getProperty(simple_name);
try {
T dao=(T) Class.forName(impl_name).newInstance();
// new cn.itcast.dao.impl.UserDaoJdbcImpl()
return dao;
} catch (Exception e) {
//
throw new RuntimeException(e);
}
}
}
BusinessServiceImplはサービスにあります.impl
パッケージ
package cn.itcast.service.impl;
import cn.itcast.dao.UserDao;
import cn.itcast.domain.User;
import cn.itcast.exception.UserExistException;
import cn.itcast.factory.DaoFactory;
import cn.itcast.utils.ServiceUtils;
/* web ,
* web , BusinessServiceImpl */
public class BusinessServiceImpl {
//private UserDao dao=new UserDaoJdbcImpl();// spring
private UserDao dao=DaoFactory.getInstance().createDao(UserDao.class);
// 1,
public void register(User user) throws UserExistException{
// , , !
boolean b=dao.find(user.getUsername());
if (b) {
// , ( ), (web ) ( )!
throw new UserExistException();
} else {
// , md5 ,
user.setPassword(ServiceUtils.md5(user.getPassword()));
dao.add(user);
}
}
// 2,
public User login(String username,String password){
// ,
password=ServiceUtils.md5(password);
// null, user
return dao.find(username, password);
}
}
JdbcUtilsはutilsにある
パッケージ
package cn.itcast.utils;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class JdbcUtils {
private static Properties pro=new Properties();
/*
* Properties
* : ,
* 1:
* 2:
* ,
* db.properties src
*/
static{
String pro_name="db.properties";
InputStream in=JdbcUtils.class.getClassLoader().getResourceAsStream(pro_name);
try {
pro.load(in);
Class.forName(pro.getProperty("driver"));
} catch (Exception e) {
//
throw new ExceptionInInitializerError(e);
}
}
// 1:
public static Connection getConnection() throws SQLException{
String url=pro.getProperty("url");
String user=pro.getProperty("user");
String password=pro.getProperty("password");
Connection conn=DriverManager.getConnection(url, user, password);
return conn;
}
// 2:
public static void release(Connection conn,Statement st,ResultSet rs){
if (conn!=null) {
try {
conn.close();
}catch (Exception e) {
// ! , 2 if
e.printStackTrace();
}
conn=null;
}
if (st!=null) {
try {
st.close();
}catch (Exception e) {
// ! , 1 if
e.printStackTrace();
}
st=null;
}
if (rs!=null) {
try {
rs.close();
}catch (Exception e) {
e.printStackTrace();
}
rs=null;
}
}
}
ServiceUtilsはutilsパッケージにあります
package cn.itcast.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import sun.misc.BASE64Encoder;
public class ServiceUtils {
public static String md5(String message){
/* ,
* md5 4 ( )*/
try {
MessageDigest md=MessageDigest.getInstance("md5");
byte[] md5=md.digest(message.getBytes());
BASE64Encoder encoder=new BASE64Encoder();
return encoder.encode(md5);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
}
WebUtilsはutilsパッケージにあります
package cn.itcast.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.Converter;
public class WebUtils {
// 1, RegisterForm
// new ,
public static <T> T request2Bean(HttpServletRequest request,Class<T> beanClass){
try{
//1. bean
T bean = beanClass.newInstance();
//2. BeanUtils request bean
Enumeration e = request.getParameterNames();//
while(e.hasMoreElements()){
String name = (String) e.nextElement(); //username password email birthday
String value = request.getParameter(name);
BeanUtils.setProperty(bean, name, value);
}
//3, RegisterForm
return bean;
}catch (Exception e) {
throw new RuntimeException(e);
}
}
// 2, RegisterForm User
public static void copyBean(Object src,Object dest){
//
//( RegisterForm User )
ConvertUtils.register(new Converter(){
public Object convert(Class type, Object value) {
/* :( value type )
*1, value null
*2, value String
*3, value
*4, SimpleDateFormat parse
*5, */
if(value==null){
return null;
}
String date=(String)value;
if("".equals(date.trim())){
return null;
}
//
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
try {
return df.parse(date);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}, Date.class);
try {
// BeanUtils bean
BeanUtils.copyProperties(dest, src);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// 3, id(UUID.randomUUID().toString())
public static String generateId(){
return UUID.randomUUID().toString();
}
}
XmlUtilsはutilsパッケージにあります
package cn.itcast.utils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
public class XmlUtils {
// XML !
private static String filepath;
static{
filepath=XmlUtils.class.getClassLoader().getResource("users.xml").getPath();
}
public static Document getDocument() throws DocumentException{
/*dom4j Document
* */
SAXReader reader=new SAXReader();
Document document=reader.read(new File(filepath));
return document;
}
public static void write2Xml(Document doc) throws IOException{
//dom4j Xml
OutputFormat format=OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
XMLWriter writer=new XMLWriter(new FileOutputStream(filepath),format);
writer.write(doc);
writer.close();
}
}
ImageServiceletはwebにあります.コントロールパッケージ
package cn.itcast.web.controller;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ImageServlet extends HttpServlet {
private static final int WIDTH=120;
private static final int HEIGHT=30;
private static final int IMAGETYPE=BufferedImage.TYPE_INT_RGB;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//
BufferedImage image=new BufferedImage(WIDTH,HEIGHT,IMAGETYPE);
Graphics g=image.getGraphics();
//
setBackground(g);
//
setBorder(g);
//
setLine(g);
// , , Graphics2D
String random=setCode((Graphics2D) g);
//
request.getSession().setAttribute("s_checkcode", random);
// , ,
response.setDateHeader("expires", -1);
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Prama", "no-cache");
response.setContentType("image/jpeg");
ImageIO.write(image, "jpg", response.getOutputStream());
}
private String setCode(Graphics2D g) {
/* :
* :
*/
g.setColor(Color.RED);
g.setFont(new Font(" ",Font.BOLD,20));
StringBuffer sb=new StringBuffer();
String base="\u7684\u4e00\u4e86\u662f\u6211\u4e0d\u5728\u4eba\u4eec\u6709\u6765\u4ed6\u8fd9\u4e0a\u7740\u4e2a\u5730\u5230\u5927\u91cc\u8bf4\u5c31\u53bb\u5b50\u5f97\u4e5f\u548c\u90a3\u8981\u4e0b\u770b\u5929\u65f6\u8fc7\u51fa\u5c0f\u4e48\u8d77\u4f60\u90fd\u628a\u597d\u8fd8\u591a\u6ca1\u4e3a\u53c8\u53ef\u5bb6\u5b66\u53ea\u4ee5\u4e3b\u4f1a\u6837\u5e74\u60f3\u751f\u540c\u8001\u4e2d\u5341\u4ece\u81ea\u9762\u524d\u5934\u9053\u5b83\u540e\u7136\u8d70\u5f88\u50cf\u89c1\u4e24\u7528\u5979\u56fd\u52a8\u8fdb\u6210\u56de\u4ec0\u8fb9\u4f5c\u5bf9\u5f00\u800c\u5df1\u4e9b\u73b0\u5c71\u6c11\u5019\u7ecf\u53d1\u5de5\u5411\u4e8b\u547d\u7ed9\u957f\u6c34\u51e0\u4e49\u4e09\u58f0\u4e8e\u9ad8\u624b\u77e5\u7406\u773c\u5fd7\u70b9\u5fc3\u6218\u4e8c\u95ee\u4f46\u8eab\u65b9\u5b9e\u5403\u505a\u53eb\u5f53\u4f4f\u542c\u9769\u6253\u5462\u771f\u5168\u624d\u56db\u5df2\u6240\u654c\u4e4b\u6700\u5149\u4ea7\u60c5\u8def\u5206\u603b\u6761\u767d\u8bdd\u4e1c\u5e2d\u6b21\u4eb2\u5982\u88ab\u82b1\u53e3\u653e\u513f\u5e38\u6c14\u4e94\u7b2c\u4f7f\u5199\u519b\u5427\u6587\u8fd0\u518d\u679c\u600e\u5b9a\u8bb8\u5feb\u660e\u884c\u56e0\u522b\u98de\u5916\u6811\u7269\u6d3b\u90e8\u95e8\u65e0\u5f80\u8239\u671b\u65b0\u5e26\u961f\u5148\u529b\u5b8c\u5374\u7ad9\u4ee3\u5458\u673a\u66f4\u4e5d\u60a8\u6bcf\u98ce\u7ea7\u8ddf\u7b11\u554a\u5b69\u4e07\u5c11\u76f4\u610f\u591c\u6bd4\u9636\u8fde\u8f66\u91cd\u4fbf\u6597\u9a6c\u54ea\u5316\u592a\u6307\u53d8\u793e\u4f3c\u58eb\u8005\u5e72\u77f3\u6ee1\u65e5\u51b3\u767e\u539f\u62ff\u7fa4\u7a76\u5404\u516d\u672c\u601d\u89e3\u7acb\u6cb3\u6751\u516b\u96be\u65e9\u8bba\u5417\u6839\u5171\u8ba9\u76f8\u7814\u4eca\u5176\u4e66\u5750\u63a5\u5e94\u5173\u4fe1\u89c9\u6b65\u53cd\u5904\u8bb0\u5c06\u5343\u627e\u4e89\u9886\u6216\u5e08\u7ed3\u5757\u8dd1\u8c01\u8349\u8d8a\u5b57\u52a0\u811a\u7d27\u7231\u7b49\u4e60\u9635\u6015\u6708\u9752\u534a\u706b\u6cd5\u9898\u5efa\u8d76\u4f4d\u5531\u6d77\u4e03\u5973\u4efb\u4ef6\u611f\u51c6\u5f20\u56e2\u5c4b\u79bb\u8272\u8138\u7247\u79d1\u5012\u775b\u5229\u4e16\u521a\u4e14\u7531\u9001\u5207\u661f\u5bfc\u665a\u8868\u591f\u6574\u8ba4\u54cd\u96ea\u6d41\u672a\u573a\u8be5\u5e76\u5e95\u6df1\u523b\u5e73\u4f1f\u5fd9\u63d0\u786e\u8fd1\u4eae\u8f7b\u8bb2\u519c\u53e4\u9ed1\u544a\u754c\u62c9\u540d\u5440\u571f\u6e05\u9633\u7167\u529e\u53f2\u6539\u5386\u8f6c\u753b\u9020\u5634\u6b64\u6cbb\u5317\u5fc5\u670d\u96e8\u7a7f\u5185\u8bc6\u9a8c\u4f20\u4e1a\u83dc\u722c\u7761\u5174\u5f62\u91cf\u54b1\u89c2\u82e6\u4f53\u4f17\u901a\u51b2\u5408\u7834\u53cb\u5ea6\u672f\u996d\u516c\u65c1\u623f\u6781\u5357\u67aa\u8bfb\u6c99\u5c81\u7ebf\u91ce\u575a\u7a7a\u6536\u7b97\u81f3\u653f\u57ce\u52b3\u843d\u94b1\u7279\u56f4\u5f1f\u80dc\u6559\u70ed\u5c55\u5305\u6b4c\u7c7b\u6e10\u5f3a\u6570\u4e61\u547c\u6027\u97f3\u7b54\u54e5\u9645\u65e7\u795e\u5ea7\u7ae0\u5e2e\u5566\u53d7\u7cfb\u4ee4\u8df3\u975e\u4f55\u725b\u53d6\u5165\u5cb8\u6562\u6389\u5ffd\u79cd\u88c5\u9876\u6025\u6797\u505c\u606f\u53e5\u533a\u8863\u822c\u62a5\u53f6\u538b\u6162\u53d4\u80cc\u7ec6";
int x=5;//
for (int i = 0; i < 4; i++) {// 4
int degree=new Random().nextInt()%30;//-30~30
String ch=base.charAt(new Random().nextInt(base.length()))+"";
sb.append(ch);
g.rotate(degree*Math.PI/180, x, 20);//Graphics2D
g.drawString(ch, x, 20);
g.rotate(-degree*Math.PI/180, x, 20);//
x+=30;// 20 10
}
return sb.toString();
}
private void setLine(Graphics g) {
g.setColor(Color.GREEN);
for (int i = 0; i < 5; i++) {
int x1=new Random().nextInt(WIDTH);
int y1=new Random().nextInt(HEIGHT);
int x2=new Random().nextInt(WIDTH);
int y2=new Random().nextInt(HEIGHT);
g.drawLine(x1, y1, x2, y2);//
}
}
private void setBorder(Graphics g) {
g.setColor(Color.BLUE);
g.drawRect(0, 0, WIDTH-1, HEIGHT-1);
}
private void setBackground(Graphics g) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, WIDTH, HEIGHT);
}
}
LoginServeretはwebにあります.コントロールパッケージ
package cn.itcast.web.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.itcast.domain.User;
import cn.itcast.service.impl.BusinessServiceImpl;
public class LoginServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
BusinessServiceImpl service = new BusinessServiceImpl();
User user = service.login(username, password);
if(user!=null){
//session
request.getSession().setAttribute("user", user);
// ,
// web day09
String url=request.getContextPath();
response.sendRedirect(url+ "/index.jsp");
return;
}
request.setAttribute("message", " !!");
request.getRequestDispatcher("/message.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
LogoutServeretはwebにあります.コントロールパッケージ
package cn.itcast.web.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class LogoutServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession(false);
if(session!=null){
session.removeAttribute("user");
}
// , ,
// 3
//
String url=request.getContextPath();//day04
request.setAttribute("message", " , 3 <meta http-equiv='refresh' content='3;url="+url+"/index.jsp'>");
request.getRequestDispatcher("/message.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
RegisterServiceletはwebにあります.コントロールパッケージ
package cn.itcast.web.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.itcast.domain.User;
import cn.itcast.exception.UserExistException;
import cn.itcast.service.impl.BusinessServiceImpl;
import cn.itcast.utils.WebUtils;
import cn.itcast.web.formbean.RegisterForm;
public class RegisterServlet extends HttpServlet {
//
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// post
request.setCharacterEncoding("UTF-8");
//1. RegisterForm ,
// RegisterForm,
RegisterForm form=WebUtils.request2Bean(request, RegisterForm.class);
String s_checkcode=(String) request.getSession().getAttribute("s_checkcode");
form.setS_checkcode(s_checkcode);
boolean b=form.validate();
//2. , ,
if(!b){
request.setAttribute("form", form);
request.getRequestDispatcher("/WEB-INF/jsp/register.jsp").forward(request, response);
return;
}
//3. , service
//( RegisterForm User )
User user=new User();
WebUtils.copyBean(form, user);
user.setId(WebUtils.generateId());
BusinessServiceImpl service=new BusinessServiceImpl();
try {
service.register(user);
// ,
//session
request.getSession().setAttribute("user", user);
String url=request.getContextPath();
request.setAttribute("message", " , !! 3 <meta http-equiv='refresh' content='3;url="+url+"/index.jsp'>");
request.getRequestDispatcher("/message.jsp").forward(request, response);
return;
} catch (UserExistException e) {
// ,
form.getErrors().put("username", " !!");
request.setAttribute("form", form);
request.getRequestDispatcher("/WEB-INF/jsp/register.jsp").forward(request, response);
return;
}catch(Exception e){
//
e.printStackTrace();
request.setAttribute("message", " !!!");
request.getRequestDispatcher("/message.jsp").forward(request, response);
return;
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
RegisterFormはwebにあります.formbeanパッケージ
package cn.itcast.web.formbean;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.beanutils.locale.converters.DateLocaleConverter;
public class RegisterForm {
/*
* String */
private String username;
private String password;
private String password2;
private String email;
private String birthday;
private String nickname;
private String c_checkcode;
private String s_checkcode;
// Map errors
private Map errors = new HashMap();
public boolean validate(){
// , ,flag
boolean flag = true;
// , 3-8
if(this.username==null || this.username.trim().equals("")){
flag = false;
errors.put("username", " !");
}else{
if(!this.username.matches("[A-Za-z]{3,8}")){
flag = false;
errors.put("username", " 3-8 !");
}
}
// , 3-8
if(this.password==null || this.password.trim().equals("")){
flag = false;
errors.put("password", " !");
}else{
if(!this.password.matches("\\d{3,8}")){
flag = false;
errors.put("password", " 3-8 !");
}
}
// ,
if(this.password2==null || this.password2.trim().equals("")){
flag = false;
errors.put("password2", " !");
}else{
if(!this.password.equals(this.password2)){
flag = false;
errors.put("password2", " !");
}
}
// ,
if(this.email==null || this.email.trim().equals("")){
flag = false;
errors.put("email", " !");
}else{
if(!this.email.matches("\\w+@\\w+(\\.\\w+)+")){
flag = false;
errors.put("email", " !");
}
}
/* , ,
* SimpleDateFormat 12 32 2
* BeanUtils DateLocaleConverter
* , !
*/
if(this.birthday!=null && !this.birthday.trim().equals("")){
try{
DateLocaleConverter conv= new DateLocaleConverter();
conv.convert(this.birthday, "yyyy-MM-dd");
}catch (Exception e) {
flag = false;
errors.put("birthday", " !");
}
}
// , (\u4e00-\u9fa5)
if(this.nickname==null || this.nickname.trim().equals("")){
flag = false;
errors.put("nickname", " !");
}else{ //[^\u4e00-\u9fa5]*
if(!this.nickname.matches("^([\u4e00-\u9fa5]+)$")){
flag = false;
errors.put("nickname", " !");
}
}
//
if(c_checkcode==null || this.c_checkcode.trim().equals("")){
flag = false;
errors.put("c_checkcode", " !");
}else{
if(!this.c_checkcode.equals(this.s_checkcode)){
flag = false;
errors.put("c_checkcode", " !");
}
}
return flag;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
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 getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getC_checkcode() {
return c_checkcode;
}
public void setC_checkcode(String c_checkcode) {
this.c_checkcode = c_checkcode;
}
public String getS_checkcode() {
return s_checkcode;
}
public void setS_checkcode(String s_checkcode) {
this.s_checkcode = s_checkcode;
}
public Map getErrors() {
return errors;
}
public void setErrors(Map errors) {
this.errors = errors;
}
}
LoginUIservletはwebにあります.UIパッケージ
package cn.itcast.web.UI;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class LoginUIServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// login.jsp
request.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
RegisterUIservletはwebにあります.UIパッケージ
package cn.itcast.web.UI;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class RegisterUIServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// register.jsp
request.getRequestDispatcher("/WEB-INF/jsp/register.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
dao.propertiesはsrcクラスディレクトリの下にあります
UserDao=cn.itcast.dao.impl.UserDaoJdbcImpl
#UserDao=cn.itcast.dao.impl.UserDaoXmlImpl
db.propertiesはsrcクラスディレクトリの下にあります
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/day14_user?useUnicode=true&characterEncoding=utf-8
user=root
password=root
#driver=oracle.jdbc.driver.OracleDriver
#url=jdbc:oracle:thin:@localhost:1521:orcl
#user=system
#password=itcast
Users.xmlはsrcクラスディレクトリの下にあります
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user id="95a08f25-ad11-4f69-8b37-65e21b809e50" username="tanchun" password="4QrcOUm6Wau+VuBX8g+IPg==" email="[email protected]" birthday="1990-09-09" nickname=" "/>
</users>
index.jspはWebRootディレクトリの下にあります
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> </title>
</head>
<body>
<c:if test="${user!=null}">
:${user.nickname }
<a href="${pageContext.request.contextPath }/servlet/LogoutServlet"> </a>
</c:if>
<c:if test="${user==null}">
<a href="${pageContext.request.contextPath }/servlet/LoginUIServlet"> </a>
<a href="${pageContext.request.contextPath }/servlet/RegisterUIServlet"> </a>
</c:if>
:
1.
2.
3. dao
<user id="8881" username="weixi" password="888" email="[email protected]" birthday="1990-09-09" nickname=" "/>
mysql -uroot -proot
set character_set_client=gb2312;
set character_set_results=gb2312;
create database day14_user;
use day14_user;
create table users
(
id varchar(40) primary key,
username varchar(40) not null unique,
password varchar(40) not null,
email varchar(100) not null unique,
birthday date,
nickname varchar(40) not null
);
show tables;
</body>
</html>
message.jspはWebRootディレクトリの下にあります
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> , </title>
</head>
<body>
${message }
</body>
</html>
ShowCalendar.jsはWebRoot/jsディレクトリの下にあります(WEB-INFに置かないでください)
//
// By Ziyue(http://www.web-v.com/)
// :
// <script type="text/javascript" src="${pageContext.request.contextPath }/js/ShowCalendar.js"></script>
// <input name="birthday" type="text" id="birthday" title=" " onClick="showCalendar(this.id)">
var today;
document.writeln("<div id='Calendar' style='position:absolute; z-index:1; visibility: hidden; filter:\"progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#999999,strength=3)\"'></div>");
function getDays(month, year)
{
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
//
if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) || (0 == year % 400) ? 29 : 28;
else
return daysInMonth[month];
}
function getToday()
{
// , ,
this.now = new Date();
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}
function getStringDay(str)
{
// , ,
var str=str.split("-")
this.now = new Date(parseFloat(str[0]),parseFloat(str[1])-1,parseFloat(str[2]));
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}
function newCalendar() {
var parseYear = parseInt(document.all.Year.options[document.all.Year.selectedIndex].value);
var newCal = new Date(parseYear, document.all.Month.selectedIndex, 1);
var day = -1;
var startDay = newCal.getDay();
var daily = 0;
if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
day = today.day;
var tableCal = document.all.calendar;
var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());
for (var intWeek = 1; intWeek < tableCal.rows.length;intWeek++)
for (var intDay = 0;intDay < tableCal.rows[intWeek].cells.length;intDay++)
{
var cell = tableCal.rows[intWeek].cells[intDay];
if ((intDay == startDay) && (0 == daily))
daily = 1;
if(day==daily) // , Class
{
cell.style.background='#6699CC';
cell.style.color='#FFFFFF';
//cell.style.fontWeight='bold';
}
else if(intDay==6) //
cell.style.color='green';
else if (intDay==0) //
cell.style.color='red';
if ((daily > 0) && (daily <= intDaysInMonth))
{
cell.innerText = daily;
daily++;
}
else
cell.innerText = "";
}
}
function GetDate(InputBox)
{
var sDate;
//
if (event.srcElement.tagName == "TD")
if (event.srcElement.innerText != "")
{
sDate = document.all.Year.value + "-" + document.all.Month.value + "-" + event.srcElement.innerText;
eval("document.all."+InputBox).value=sDate;
HiddenCalendar();
}
}
function HiddenCalendar()
{
//
document.all.Calendar.style.visibility='hidden';
}
function showCalendar(InputBox)
{
var months = new Array(" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ");
var days = new Array(" "," ", " ", " ", " ", " ", " ");
var x,y,intLoop,intWeeks,intDays;
var DivContent;
var year,month,day;
var o=eval("document.all."+InputBox);
var thisyear; //
thisyear=new getToday();
thisyear=thisyear.year;
today = o.value;
if(isDate(today))
today = new getStringDay(today);
else
today = new getToday();
//
x=o.offsetLeft;
y=o.offsetTop;
while(o=o.offsetParent)
{
x+=o.offsetLeft;
y+=o.offsetTop;
}
document.all.Calendar.style.left=x+2;
document.all.Calendar.style.top=y+20;
document.all.Calendar.style.visibility="visible";
// (border-color:#9DBAF7)
DivContent="<table border='0' cellspacing='0' style='border:1px solid #0066FF; background-color:#EDF2FC'>";
DivContent+="<tr>";
DivContent+="<td style='border-bottom:1px solid #0066FF; background-color:#C7D8FA'>";
//
DivContent+="<select name='Year' id='Year' onChange='newCalendar()' style='font-family:Verdana; font-size:12px'>";
for (intLoop = thisyear - 35; intLoop < (thisyear + 2); intLoop++)
DivContent+="<option value= " + intLoop + " " + (today.year == intLoop ? "Selected" : "") + ">" + intLoop + "</option>";
DivContent+="</select>";
//
DivContent+="<select name='Month' id='Month' onChange='newCalendar()' style='font-family:Verdana; font-size:12px'>";
for (intLoop = 0; intLoop < months.length; intLoop++)
DivContent+="<option value= " + (intLoop + 1) + " " + (today.month == intLoop ? "Selected" : "") + ">" + months[intLoop] + "</option>";
DivContent+="</select>";
DivContent+="</td>";
DivContent+="<td style='border-bottom:1px solid #0066FF; background-color:#C7D8FA; font-weight:bold; font-family:Wingdings 2,Wingdings,Webdings; font-size:16px; padding-top:2px; color:#4477FF; cursor:hand' align='center' title=' ' onClick='javascript:HiddenCalendar()'>S</td>";
DivContent+="</tr>";
DivContent+="<tr><td align='center' colspan='2'>";
DivContent+="<table id='calendar' border='0' width='100%'>";
//
DivContent+="<tr>";
for (intLoop = 0; intLoop < days.length; intLoop++)
DivContent+="<td align='center' style='font-size:12px'>" + days[intLoop] + "</td>";
DivContent+="</tr>";
//
for (intWeeks = 0; intWeeks < 6; intWeeks++)
{
DivContent+="<tr>";
for (intDays = 0; intDays < days.length; intDays++)
DivContent+="<td onClick='GetDate(\"" + InputBox + "\")' style='cursor:hand; border-right:1px solid #BBBBBB; border-bottom:1px solid #BBBBBB; color:#215DC6; font-family:Verdana; font-size:12px' align='center'></td>";
DivContent+="</tr>";
}
DivContent+="</table></td></tr></table>";
document.all.Calendar.innerHTML=DivContent;
newCalendar();
}
function isDate(dateStr)
{
var datePat = /^(\d{4})(\-)(\d{1,2})(\-)(\d{1,2})$/;
var matchArray = dateStr.match(datePat);
if (matchArray == null) return false;
var month = matchArray[3];
var day = matchArray[5];
var year = matchArray[1];
if (month < 1 || month > 12) return false;
if (day < 1 || day > 31) return false;
if ((month==4 || month==6 || month==9 || month==11) && day==31) return false;
if (month == 2)
{
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) return false;
}
return true;
}
login.jspはWebRoot/WEB-INF/JSPディレクトリの下にあります
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> </title>
</head>
<body>
<form action="${pageContext.request.contextPath }/servlet/LoginServlet" method="post">
:<input type="text" name="username" />
:<input type="password" name="password" />
<input type="submit" value=" " />
<input type="button" value=" " onclick="window.location.href='${pageContext.request.contextPath }/servlet/RegisterUIServlet'" />
</form>
</body>
</html>
register.jspはWebRoot/WEB-INF/JSPディレクトリの下にあります
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> </title>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/ShowCalendar.js"></script>
</head>
<body>
<h3> :</h3>
1: , 《 》, , , , , , 。
<form action="${pageContext.request.contextPath }/servlet/RegisterServlet" method="post">
<table>
<tr>
<td > :</td>
<td>
<input type="text" name="username" value="${form.username }">
<span >${form.errors.username }</span>
</td>
</tr>
<tr>
<td > :</td>
<td>
<input type="password" name="password" value="${form.password }">
<span >${form.errors.password }</span>
</td>
</tr>
<tr>
<td > :</td>
<td>
<input type="password" name="password2" value="${form.password2 }">
<span >${form.errors.password2 }</span>
</td>
</tr>
<tr>
<td > :</td>
<td>
<input type="text" name="email" value="${form.email }">
<span >${form.errors.email }</span>
</td>
</tr>
<tr>
<td > :</td>
<td>
<input type="text" name="birthday" id="birthday" title=" " onClick="showCalendar(this.id)" value="${form.birthday }">
<span >${form.errors.birthday }</span>
</td>
</tr>
<tr>
<td > :</td>
<td>
<input type="text" name="nickname" value="${form.nickname }">
<span >${form.errors.nickname }</span>
</td>
</tr>
<tr>
<td > :</td>
<td>
<input type="text" name="c_checkcode">
<span >${form.errors.c_checkcode }</span>
<img src="${pageContext.request.contextPath }/servlet/ImageServlet" height="25px" width="120px" alt=" " style="cursor: hand;" onclick="this.src=this.src+'?'+Math.random().toString().substr(2,3)">
</td>
</tr>
</table>
<span><input class="btn" type="reset" name="reset" value=" "></span>
<span><input class="btn" type="submit" name="submit" value=" "></span>
</form>
</body>
</html>