190717_Day68 <회원가입 미션>
<미션2>
==> 사용자인증JSP : Model1사용, DAO만 Model2개발방식!!
userinput.jsp (사용자정보 입력폼, 회원가입폼)
userprocess.jsp (사용자정보 DB저장)
- insert
userconfirm.jsp (로그인 화면폼)
confirmprocess.jsp (로그인 처리: 아이디, 비번에 대한 존재와 일치를 체크)
- select
modifyuser.jsp (사용자정보 수정폼)
- select
modifyprocess.jsp (사용자정보 DB수정처리)
- update
deleteid.jsp (사용자정보 DB삭제, 회원탈퇴)
- delete
confirmid.jsp (아이디 중복여부 처리)
- select
service.jsp <
========
테이블명: UserInfo
<SQL스크립트 DDL>
drop table userinfo;
create table userinfo(
id varchar2(20) constraint userinfo_pk primary key,
pass varchar2(20) not null,
name varchar2(30) not null,
jumin varchar2(14) not null,
birth varchar2(10),
zip number(5) not null,
addr varchar2(300),
email varchar2(50) not null,
job varchar2(30) not null
);
작업순서)
회원정보입력
1. userinput.jsp(입력폼,회원가입폼)에서 '월'과 '일'에 대한 숫자 출력.
월: 01~09~12 (자바for문을 통해 출력)
2. UserInfo.java작성 (테이블의 한 레코드 표현)
3. UserInfoDAO.java작성
4. DB insert작업(userprocess.jsp)
DAO의 insert호출
5. userconfirm.jsp (로그인화면)
- UserInfoDAO의 selectLogin() 메소드 구현
- 로그인 처리
- 호출결과에 따라 적당한 메시지 출력
- 로그인 성공시 세션적용(설정)
6. 수정폼에 기존 데이터 뿌리기
- UserInfoDAO클래스내에 select()메소드 구현
- 호출 후 결과값을 HTML에 뿌려주기
7. 수정폼에 입력된 데이터를 실제 DB에 반영
- UserInfoDAO클래스내에 modify()메소드 구현
- 수정항목: 비번,우편번호,주소,이메일,직업
- 호출 결과에 따라 적당한 메시지(table) 출력
8. 삭제(회원탈퇴)버튼 클릭시 - deleteid.jsp
- 정말 삭제할지를 확인 (JavaScript confirm창)
- DB에서 삭제처리
- 호출 결과에 따라 적당한 메시지(table) 출력
9. 입력폼에 있는 '아이디 중복확인'에 대한 처리
10. 입력폼과 수정폼의 데이터 입력에 대한 유효성검사.
(빈값, 주민번호에 대한 숫자체크와 자릿수,
이메일에 대한 유효성검사- gildong1004@naver.com)
- [영문자와 숫자조합6~15]@[영문자].[영문자]
userinput.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>
<script type="text/javascript">
function birthChange(){
console.log('birthChange')
var jumin1 = document.frm.jumin1.value ;
var birthYear = jumin1.substr(0, 2);
var ch = document.frm.jumin2.value.charAt(0);
if(ch=='1' || ch=='2' || ch=='5' || ch=='6'){
birthYear = '19'+ birthYear
}else{
birthYear = '20'+ birthYear
}
document.frm.year.value = birthYear;
document.frm.month.value = jumin1.substr(2, 2);
document.frm.day.value = jumin1.substr(4, 2);
}
function ckid(){
var id = document.frm.id.value;
if(id==''){
alert('아이디를 입력!!');
return;
}
window.open('confirmid.jsp?id='+ id,'confirm',
'toolbar=no,location=no,status=no,'
+'menubar=no,scrollbars=no,resizable=no,'
+'width=300,height=200,top=200,left=300');
}
function validateCheck(){
var f = document.frm;
var jumin1Exp = new RegExp("^[\\d]{6}$");
var jumin2Exp = /^[\d]{7}$/;
var yearExp = /^[\d]{4}$/;
var zipExp = /^[\d]{5}$/;
var idExp = /^[a-zA-Z0-9]{6,20}$/;
var emailExp = /^[a-zA-Z0-9]+@[a-zA-Z]+\.[a-zA-Z]+$/;
if(!idExp.test( document.frm.id.value))
{
alert('아이디는 6~20자리!!');
f.id.focus();
}else if (f.pass.value=='')
{
alert('비번 입력');
f.pass.focus();
}else if (f.pass2.value=='')
{
alert('비번 확인 입력');
f.pass2.focus();
}else if (f.pass.value!= f.pass2.value)
{
alert('비밀번호가 일치하지 않습니다.');
f.pass.value = ''; f.pass2.value='';
f.pass.focus();
}else if (f.name.value=='')
{
alert('이름 입력');
f.name.focus();
}
else if (!jumin1Exp.test(f.jumin1.value)||
!jumin2Exp.test(f.jumin2.value))
{
alert('잘못된 주민번호 입력입니다.');
f.jumin1.value=''; f.jumin2.value='';
f.jumin1.focus();
}else if (!yearExp.test(f.year.value))
{
alert('생년에 4자리 수 입력!');
f.year.value='';
f.year.focus();
}else if (!zipExp.test(f.zip.value))
{
alert('잘못된 우편번호');
f.zip.value='';
f.zip.focus();
}else if(!emailExp.test(f.email.value))
{
alert('이메일 빼애애액!');
f.email.value='';
f.email.focus();
}else if(f.job.value == '==선택==')
{
alert('직업 선택!');
}else{
f.submit();
}
}
</script>
</head>
<%-- userinput.jsp --%>
<body>
<center>
<form name="frm" action="userprocess.jsp" method="post">
<table width="600" border="0" cellpadding="5" >
<tr bgcolor="#3399cc">
<td><font size="4" color="white">사용자정보입력</font>
</tr>
<tr>
<td>안녕하세요. 이 페이지를 자유롭게 이용하려면
먼저 회원가입을 하셔야 합니다.<br>
아래의 사항들을 빠짐없이 기록해 주세요.
</td>
</tr>
</table>
<table border="1" cellpadding="5" width="600">
<tr>
<td width="100" bgcolor="#ffcccc">사용자ID<font color="red">*</font></td>
<td colspan="3"><input type="text" name="id">
<input type="button" value="중복확인" onclick="ckid()">
<font color="blue">(6자리~20자리)</font>
</td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">비밀번호<font color="red">*</font></td>
<td><input type="password" name="pass"> </td>
<td width="100" bgcolor="#ffcccc">비번확인</td>
<td><input type="password" name="pass2"> </td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">사용자이름<font color="red">*</font></td>
<td colspan="3"><input type="text" name="name"> </td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">주민번호<font color="red">*</font></td>
<td colspan="3">
<input type="text" name="jumin1" size="6" maxlength="6"
style="height:23px" >
-
<input type="password" name="jumin2" size="7" maxlength="7"
style="height:23px" onblur="birthChange()"></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc" >생년월일</td>
<td colspan="3">
<input type="text" name="year" size="4" maxlength="4">년
<select name="month">
<% for(int i=1; i<13; i++){
if(i<10){%>
<option>0<%=i%></option> <%}
else{ %>
<option><%=i%></option>
<%}//else
}//for %>
</select>월
<select name="day" >
<c:forEach begin="1" end="31" var="i">
<c:if test="${i<10 }"><option>0${i}</option></c:if>
<c:if test="${i>9 }"><option>${i}</option></c:if>
</c:forEach>
</select>일
</td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">우편번호<font color="red">*</font></td>
<td colspan="3">
<input type="text" name="zip" size="5" maxlength="5"></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">주소</td>
<td colspan="3"><input type="text" name="addr" size="50"></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">E-Mail<font color="red">*</font></td>
<td colspan="3"><input type="text" name="email" size="30"></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">직업<font color="red">*</font></td>
<td colspan="3">
<select name="job" >
<%
String jobs[]={"==선택==","학생","공무원","언론/출판","군인/경찰","일반사무직",
"영업직","기술/전문직","보건/의료","자영업","주부","기타" };
pageContext.setAttribute("jobs", jobs);
%>
<c:forEach items="${jobs }" var="jobName">
<option>${jobName }</option>
</c:forEach>
</select>
</td>
</tr>
<tr align="center">
<td colspan="4">
<%--
<script>
fuction validateCheck()
{
if(반값이라면)
{
alert('입력하세요')
}else
{
frm.submit();
}
}
</script>
=========================이렇게 하거나
등록 을 submit으로 하고 싶다면
<script>
fuction validateCheck()
{
if(반값이라면)
{
alert('입력하세요')
return false;
}else
{
return true;
}
}
</script>
<input type = "submit" value="등록"
onclick="reuturn validateCheck()">
--%>
<input type="button" value="등록" onclick="validateCheck()" >
<input type="reset" value="취소">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
- 주민번호 입력하면, onblur 통해서 birthChange() 메소드 호출하고, 해당 메소드 내에서 주민번호 앞자리 jumin1 을 substr 통해 나누고 나눈 값을 통해 다음에 들어가는 생년월일 value 넣어줌
UserInfo.java (t0717.vo안에)
private String id;
private String pass;
private String name;
private String jumin;
private String birth;
private int zip;
private String addr;
private String email;
private String job;
public String getId()
UserInfoDAO.java
package t0717.dao;
import java.sql.SQLException;
import java.util.List;
import t0717.vo.UserInfo;
import com.ibatis.sqlmap.client.SqlMapClient;
import iba.MySqlMapClient;
public class UserInfoDAO {
SqlMapClient sqlMap;
public UserInfoDAO() {
sqlMap = MySqlMapClient.getSqlMapInstance();
}
public boolean create(UserInfo user) {
try {
sqlMap.insert("userinfo.create", user);
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
public boolean modify(UserInfo user) throws SQLException {
if(sqlMap.update("userinfo.modify", user) == 1) {
return true;
}
return false;
}
public boolean remove(String id) throws SQLException {
if(sqlMap.delete("userinfo.remove", id) == 1) {
return true;
}
return false;
}
public UserInfo select(String id) throws SQLException {
return (UserInfo) sqlMap.queryForObject("userinfo.select",id);
}
public List<UserInfo> selectAll() {return null;}
public String selectLogin(String id) throws SQLException {
return (String) sqlMap.queryForObject("userinfo.selectLogin", id );
}
public Integer selectExistId(String id) throws SQLException {
return (Integer) sqlMap.queryForObject("userinfo.selectExistId", id );
}
}
userinfo.sql
drop table userinfo;
create table userinfo(
id varchar2(20) constraint userinfo_pk primary key,
pass varchar2(20) not null,
name varchar2(30) not null,
jumin varchar2(14) not null,
birth varchar2(10),
zip number(5) not null,
addr varchar2(300),
email varchar2(50) not null,
job varchar2(30) not null
);
SELECT * FROM USERINFO;
userinfo.xml(mapper안에 생성시 ibatis)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd" >
<sqlMap namespace="userinfo">
<typeAlias alias="user" type="t0717.vo.UserInfo"/>
<insert id="create" parameterClass="user">
insert into userinfo (id,pass,name,jumin,birth,zip,addr,email,job)
values (#id#,#pass#,#name#,#jumin#,#birth#,#zip#,#addr#,#email#,#job#)
</insert>
<update id="modify" parameterClass="user">
update userinfo
set pass=#pass#, zip=#zip#, addr=#addr#, email=#email#, job=#job#
where id = #id#
</update>
<delete id="remove" parameterClass="String">
delete from userinfo
where id=#id#
</delete>
<select id="selectLogin" parameterClass="String"
resultClass="String" >
select pass from userinfo where id=#id#
</select>
<select id="select" parameterClass="String"
resultClass="user">
select id,pass,name,jumin,birth,zip,addr,email,job
from userinfo
where id=#id#
</select>
<select id="selectExistId" parameterClass="String" resultClass="int">
select count(*)
from userinfo
where id=#id#
</select>
</sqlMap>
userprocess.jsp
<%@page import="t0717.dao.UserInfoDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:useBean class="t0717.vo.UserInfo" id="user"/>
<%-- UserInfo user = new UserInfo(); --%>
<% System.out.println("userBean실행==>"+ user); %>
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:setProperty name="user" property="*" />
<%-- user.setId(request.getParameter("id")); --%>
<% System.out.println("setProperty실행==>"+ user);
String jumin = request.getParameter("jumin1")
+"-"+request.getParameter("jumin2");
String birth = request.getParameter("year")+"-"+
request.getParameter("month")+"-"+
request.getParameter("day");
user.setJumin(jumin);
user.setBirth(birth);
System.out.println("setJumin,setBirth실행==>"+ user);
%>
<!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>
</head>
<body>
<center>
<%
//폼안의 데이터 얻기: String data = request.getParameter("name속성값");
UserInfoDAO dao = new UserInfoDAO();
if(dao.create(user)){
%>
<table width="330" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>[${param.name }]님 가입을 축하합니다.</b></td>
</tr>
<tr>
<td>
입력하신 내용대로 가입이 완료되었습니다.<br>
님께서 요청하신 아이디와 패스워드입니다.
<p align="center">아이디: ${param.id }<br>
패스워드: ${param.pass }<br><br>
<a href="userconfirm.jsp">로그인 화면</a>
</p>
</td>
</tr>
</table>
<%}else{ %>
<table width="330" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>가입이 되지않았습니다.<br>
입력내용을 다시 한번 확인해 주세요.</b></td>
</tr>
<tr>
<td>
<p align="center">입력이 정확한 경우에도 가입이 되지 않는 경우
관리자에게 문의하여 주십시요. <br>
<a href="javascript:history.back()">이전화면</a>
</p>
</td>
</tr>
</table>
<%} %>
</center>
</body>
</html>
sqlMapConfig.xml 에 xml파일 등록!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd" >
<sqlMapConfig>
<properties resource="./iba/conn.properties"/>
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="30"
maxSessions="25"
maxTransactions="10"
useStatementNamespaces="true"
/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}"/>
<property name="JDBC.ConnectionURL" value="${url}"/>
<property name="JDBC.Username" value="${user}"/>
<property name="JDBC.Password" value="${password}"/>
</dataSource>
</transactionManager>
<sqlMap resource="./mapper/counter.xml"/>
<sqlMap resource="./mapper/emp.xml"/>
<sqlMap resource="./mapper/userinfo.xml"/>
</sqlMapConfig>
- 앞으로 귀찮으면
- < sqlMap resource="./mapper/*.xml"/> 해도 됨.
service.jsp (로그인 성공 후 접속 할 수 있는 페이지)
<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Session인증 페이지</title>
<style type="text/css">
<!--
.normal { font-family: "굴림", "돋움"; font-size: x-small; font-style: normal; font-weight: normal; text-decoration: none}
.normalbold { font-family: "굴림", "돋움"; font-size: x-small; font-style: normal; font-weight: bold; text-decoration: none}
-->
</style>
</head>
<%-- service.jsp --%>
<%
String login = (String)session.getAttribute("login");
if(login ==null || !login.equals("success")){//로그인 하지 않았다면!!
response.sendRedirect("userconfirm.jsp");
}
%>
<body>
<center>
<p>
<img src="<%= application.getInitParameter("imgPath")%>/ebi.gif" width="400" height="300">
<img src="${initParam.imgPath }/ebi.gif" width="400" height="300">
</p>
<p class="normalbold">이 페이지는 사용자 인증을 받아야 볼 수 있죠!</p>
<p class="normal">감사합니다....</p>
<p class="normal"><a href="userconfirm.jsp">로그아웃</a></p>
</center>
</body>
</html>
- confirmprocess.jsp 에 로그인 성공시 성공 정보(login)을 success로 남기는 세션정보를 추가해야 한다.
confirmprocess.jsp
<%@page import="t0717.dao.UserInfoDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>
<script type="text/javascript">
function movePage(upDel){
if(upDel=='up')
location.href='modifyuser.jsp?id=${param.id}';
else
{
if(confirm('정말탈퇴하시겠습니까?'))
{
location.href='deleteid.jsp?id=${param.id}';
}
}
}
</script>
</head>
<body>
<%
String id = request.getParameter("id");
String pass = request.getParameter("pass");
UserInfoDAO dao = new UserInfoDAO();
String dpass = dao.selectLogin(id);
if(dpass != null){//아이디 O
if(dpass.equals(pass)){//아이디O , 패스워드 일치
//로그인 성공 정보를 세션에 남기기 (세션 로그인)
session.setAttribute("login", "success");
//session.setAttribute("loginID", id);
%>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>로그인 성공</b></td>
</tr>
<tr>
<td>
입력하신 아이디와 패스워드를<br> 확인했습니다.
<br><br>
<input type="button" value="회원정보수정" onclick="movePage('up')">
<input type="button" value="회원탈퇴" onclick="movePage('del')" >
<br><br>
<a href="service.jsp">서비스화면</a>
</td>
</tr>
</table>
<% }else{//아이디O , 패스워드 불일치%>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>로그인 실패</b></td>
</tr>
<tr>
<td>
패스워드가 틀립니다.<br>
패스워드를 다시한번 확인해 주시기 바랍니다.<br><br>
<a href="userconfirm.jsp">로그인화면</a>
</td>
</tr>
</table>
<% }
}else{//아이디 X%>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>로그인 실패</b></td>
</tr>
<tr>
<td>
다시 아이디를 확인하세요.<br>
만약 가입하지 않으신 경우 신규가입을 하시기 바랍니다.<br><br>
<a href="userinput.jsp">신규가입</a>
</td>
</tr>
</table>
<% }%>
</center>
</body>
</html>
- 조건( 로그인 성공, 실패 (아이디틀림, 비밀번호 틀림) ) 에 따라 뜨는 페이지를 테이블을 설정하게 함.
- 로그인 성공시 세션 정보를 남김
service.jsp
<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Session인증 페이지</title>
<style type="text/css">
<!--
.normal { font-family: "굴림", "돋움"; font-size: x-small; font-style: normal; font-weight: normal; text-decoration: none}
.normalbold { font-family: "굴림", "돋움"; font-size: x-small; font-style: normal; font-weight: bold; text-decoration: none}
-->
</style>
</head>
<%-- service.jsp --%>
<%
String login = (String)session.getAttribute("login");
if(login ==null || !login.equals("success")){//로그인 하지 않았다면!!
response.sendRedirect("userconfirm.jsp");
}
%>
<body>
<center>
<p>
<img src="/TomTest/image/ebi.gif" width="400" height="300">
</p>
<p class="normalbold">이 페이지는 사용자 인증을 받아야 볼 수 있죠!</p>
<p class="normal">감사합니다....</p>
<p class="normal"><a href="sessionT4.jsp">로그아웃</a></p>
</center>
</body>
</html>
modifyuser.jsp
<%@page import="t0717.vo.UserInfo"%>
<%@page import="t0717.dao.UserInfoDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>
<script type="text/javascript" src="/TomTest/js/check.js"></script>
</head>
<%
UserInfoDAO dao = new UserInfoDAO();
UserInfo user = dao.select(request.getParameter("id"));
System.out.println("user>>>"+ user);
String []jumin=user.getJumin().split("-");//"960302-2012345"
//{"960302","2012345"}
String []birth = user.getBirth().split("-");//"1996-03-02"
//{"1996","03","02"}
pageContext.setAttribute("user", user);
%>
<body>
<center>
<form name="frm" action="modifyprocess.jsp" method="post">
<table width="600" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><font size="4" color="white">사용자정보수정</font>
</tr>
</table>
<table border="1" cellpadding="5" width="600">
<tr>
<td width="100" bgcolor="#ffcccc">사용자ID</td>
<td colspan="3">
<%-- <input type="text" name="id" value="<%= user.getId()%>"></td> --%>
<input type="text" name="userid" value="${user.id }" disabled>
<input type="hidden" name="id" value="${user.id }">
<%-- disabled는 못받아와, 그래서 hidden씀 --%>
</td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">비밀번호</td>
<td><input type="password" name="pass" value="${user.pass }">
</td>
<td width="100" bgcolor="#ffcccc">비번확인</td>
<td><input type="password" name="pass2" value="${user.pass }">
</td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">사용자이름</td>
<td colspan="3"><input type="text" name="name"
value="${user.name }" readonly></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">주민번호</td>
<td colspan="3"><input type="text" name="jumin1" size="6"
maxlength="6" style="height: 23px" value="<%= jumin[0]%>" readonly>
- <input type="password" name="jumin2" size="7" maxlength="7"
style="height: 23px" value="<%= jumin[1]%>" readonly></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">생년월일</td>
<td colspan="3"><input type="text" name="year" size="4"
maxlength="4" value="<%= birth[0]%>" disabled>년 <select
name="month" disabled>
<option><%=birth[1] %></option>
</select>월 <select name="day" disabled>
<option><%=birth[2] %></option>
</select>일</td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">우편번호</td>
<td colspan="3"><input type="text" name="zip" size="5"
maxlength="5" value="${user.zip }"></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">주소</td>
<td colspan="3"><input type="text" name="addr" size="50"
value="${user.addr }"></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">E-Mail</td>
<td colspan="3"><input type="text" name="email" size="30"
value="${user.email }"></td>
</tr>
<tr>
<td width="100" bgcolor="#ffcccc">직업</td>
<td colspan="3"><select name="job">
<%
String jobs[]={"==선택==","학생","공무원","언론/출판","군인/경찰","일반사무직",
"영업직","기술/전문직","보건/의료","자영업","주부","기타" };
for(int i=0; i<jobs.length; i++){
if(jobs[i].equals(user.getJob()))
out.print("<option selected>"+ jobs[i] +"</option>");
else
out.print("<option>"+ jobs[i] +"</option>");
} %>
</select></td>
</tr>
<tr align="center">
<td colspan="4"><input type="button" value="수정" onclick = validateCheck()>
<input
type="reset" value="취소"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
modifyprocess.jsp
<%@page import="t0717.dao.UserInfoDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:useBean class="t0717.vo.UserInfo" id="user" />
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:setProperty property="*" name="user" />
<!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>
</head>
<body>
<center>
<%
UserInfoDAO dao = new UserInfoDAO();
try
{
if(dao.modify(user)){
%>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>수정성공</b></td>
</tr>
<tr>
<td>수정이 잘되었습니다<br>
<br> <a href="service.jsp">서비스페이지</a>
</td>
</tr>
</table>
<%}else{ %>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>수정실패</b></td>
</tr>
<tr>
<td>정보수정이 되지않았습니다.<br> 입력내용을 다시확인하시고 다시수정하시기 바랍니다.<br>
<br> <a href="javascript:history.go(-1)">이전화면</a>
</td>
</tr>
</table>
<%} }
catch(Exception e)
{ %>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>수정실패</b></td>
</tr>
<tr>
<td>정보수정이 되지않았습니다.<br> 입력내용을 다시확인하시고 다시수정하시기 바랍니다.<br>
<br> <a href="javascript:history.go(-1)">이전화면</a>
</td>
</tr>
</table>
<%}
%>
</center>
</body>
</html>
confirmid.jsp
<%@page import="t0717.dao.UserInfoDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>Insert title here</title>
<script>
</script>
</head>
<%-- confirmid.jsp --%>
<body>
<center>
<%--주소?id=yong 이렇게 나오게 하려면 --%>
<%
String id = request.getParameter("id");
System.out.println("파라미터 아이디 : " + id);
UserInfoDAO dao = new UserInfoDAO();
if( dao.selectExistId(id) == 1){ //아이디 존재 하면 1 아니면 0
%>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>사용불가능</b></td>
</tr>
<tr>
<td>
이미 사용중인 아이디입니다.<br>
다른 아이디를 선택하십시요!!
</td>
</tr>
</table>
<input type="button" value="닫기" onclick="window.close()">
<% }else{ %>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>사용가능</b></td>
</tr>
<tr>
<td>
사용가능한 아이디입니다^^*
</td>
</tr>
</table>
<a href="javascript:self.close()">창닫기</a>
<% } %>
</center>
</body>
</html>
deleteid.jsp
<%@page import="t0717.dao.UserInfoDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>Insert title here</title>
</head>
<body>
<center>
<%
String id = request.getParameter("id");
UserInfoDAO dao = new UserInfoDAO();
if(dao.remove(id))
{
session.invalidate();
%>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>삭제성공</b></td>
</tr>
<tr>
<td>
삭제가 잘되었습니다.<br>
이용해 주셔서 감사합니다.
<br><br>
<a href="service.jsp">서비스페이지</a>
</td>
</tr>
</table>
<%
}else
{ %>
<table width="280" border="0" cellpadding="5">
<tr bgcolor="#3399cc">
<td><b>삭제실패</b></td>
</tr>
<tr>
<td>
삭제가 되지않았습니다.<br>
잠시 후 다시 시도해 보시기 바랍니다.<br><br>
<a href="javascript:history.go(-1)">이전화면</a>
</td>
</tr>
</table>
<%}
%>
</center>
</body>
</html>