๐Ÿ‘“๊ฐ„๋‹จํ•œ ์›นํŽ˜์ด์ง€ ๋งŒ๋“ค๊ธฐ - ํšŒ์›๊ฐ€์ž…

์ž„์Šนํ˜„ยท2022๋…„ 12์›” 13์ผ
0

JSP

๋ชฉ๋ก ๋ณด๊ธฐ
16/20
  1. webappํด๋” cssํด๋” ์ƒ์„ฑ
    style.css ์ƒ์„ฑ
  1. web-infํด๋”
    index.jsp ์ƒ์„ฑ

    header.jsp ์ƒ์„ฑ
    footer.jsp ์ƒ์„ฑ
  1. webappํด๋” mainํด๋” ์ƒ์„ฑ
    main_page ์ƒ์„ฑ

  2. webappํด๋” memberํด๋” ์ƒ์„ฑ
    member_join.jsp ์ƒ์„ฑ
    member_login.jsp ์ƒ์„ฑ

  3. webappํด๋” productํด๋” ์ƒ์„ฑ
    product_list.jsp

  4. webappํด๋” cartํด๋” ์ƒ์„ฑ
    cart_list.jsp

  5. webappํด๋” orderํด๋” ์ƒ์„ฑ
    order_list.jsp

  6. webappํด๋” boardํด๋” ์ƒ์„ฑ
    board_list.jsp

================================================

๐ŸŒˆPart 1 - ํ…Œ์ด๋ธ” ๋งŒ๋“ค๊ธฐ

โ—ˆ SQL Delope ์‹คํ–‰

create table member(id varchar(20) primary key
    ,passwd varchar2(200),name varchar2(20),email varchar2(30)
    ,mobile varchar2(20),zipcode varchar2(10)
    ,address1 varchar(200), address2 varchar(50)
    ,join_data date,last_login date,status number(1));

๐ŸŒˆPart 2 - MemberDTO.java ๋งŒ๋“ค๊ธฐ

โ—ˆ xyz.itwill.dto ํŒจํ‚ค์ง€์— MemberDTO ํด๋ž˜์Šค ์ƒ์„ฑ

๐Ÿ“ƒMemberDTO.java

package xyz.itwill.dto;
//
/*
์ด๋ฆ„         ๋„?       ์œ ํ˜•            
---------- -------- ------------- 
ID         NOT NULL VARCHAR2(20)  - ์•„์ด๋””
PASSWD              VARCHAR2(200) - ๋น„๋ฐ€๋ฒˆํ˜ธ
NAME                VARCHAR2(20)  - ์ด๋ฆ„
EMAIL               VARCHAR2(30)  - ์ด๋ฉ”์ผ
MOBILE              VARCHAR2(20)  - ์ „ํ™”๋ฒˆํ˜ธ
ZIPCODE             VARCHAR2(10)  - ์šฐํŽธ๋ฒˆํ˜ธ
ADDRESS1            VARCHAR2(200) - ๊ธฐ๋ณธ์ฃผ์†Œ
ADDRESS2            VARCHAR2(50)  - ์ƒ์„ธ์ฃผ์†Œ
JOIN_DATA           DATE          - ํšŒ์›๊ฐ€์ž…๋‚ ์งœ
LAST_LOGIN          DATE          - ๋งˆ์ง€๋ง‰ ๋กœ๊ทธ์ธ ๋‚ ์งœ
STATUS              NUMBER(1) 	  - ํšŒ์›์ƒํƒœ : 0(ํƒˆํ‡ดํšŒ์›), 1(์ผ๋ฐ˜ํšŒ์›), 9(๊ด€๋ฆฌ์ž)
 */
//
public class MemberDTO {
	private String id;
	private String passwd;
	private String name;
	private String email;
	private String mobile;
	private String zipcode;
	private String address1;
	private String address2;
	private String joinDate;
	private String lastLogin;
	private int status;
	//
	public MemberDTO() {
		// TODO Auto-generated constructor stub
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getPasswd() {
		return passwd;
	}
	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	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 getZipcode() {
		return zipcode;
	}
	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}
	public String getAddress1() {
		return address1;
	}
	public void setAddress1(String address1) {
		this.address1 = address1;
	}
	public String getAddress2() {
		return address2;
	}
	public void setAddress2(String address2) {
		this.address2 = address2;
	}
	public String getJoinDate() {
		return joinDate;
	}
	public void setJoinDate(String joinDate) {
		this.joinDate = joinDate;
	}
	public String getLastLogin() {
		return lastLogin;
	}
	public void setLastLogin(String lastLogin) {
		this.lastLogin = lastLogin;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
}

๐ŸŒˆPart 3 - MemberDTO.java ๋งŒ๋“ค๊ธฐ

โ—ˆ xyz.itwill.dao ํŒจํ‚ค์ง€์— MemberDAO ํด๋ž˜์Šค ์ƒ์„ฑ

๐Ÿ“ƒMemberDAO.java

์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”

================================================

๐ŸŒˆPart 4 - MemberDTO.java ๋งŒ๋“ค๊ธฐ

ํšŒ์›๊ฐ€์ž… ๊ด€๋ จ
1. member_join.jsp ์ˆ˜์ •
2. member_join_action.jsp ์ƒ์„ฑ ๋ฐ ์ž‘์„ฑ

================================================

๐ŸŒˆPart 5 - ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” ์ฒ˜๋ฆฌ

1. xyz.itwill.util ํŒจํ‚ค์ง€ ์ƒ์„ฑ
2. Uitility ํด๋ž˜์Šค ์ƒ์„ฑ
์•”ํ˜ธํ™” ์ฒ˜๋ฆฌ ์ „์—๋Š” ๊ฐœ์ธ์ •๋ณด๊ฐ€ ์ „๋ถ€ ํ‘œ์‹œ๋จ


โ€ปtruncate table member;(ํ…Œ์ด๋ธ” ์ดˆ๊ธฐํ™” ๋ช…๋ น์–ด)
์•”ํ˜ธํ™” ์ฒ˜๋ฆฌ ํ›„

๐Ÿ“ƒUitility.java

package xyz.itwill.util;
//
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
//
//์›นํ”„๋กœ๊ทธ๋žจ ์ž‘์„ฑ์— ํ•„์š”ํ•œ ๋ถ€๊ฐ€์ ์ธ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•œ ํด๋ž˜์Šค
public class Utility {
	//๋ฌธ์ž์—ด์„ ์ „๋‹ฌ๋ฐ›์•„ ์•”ํ˜ธํ™” ์ฒ˜๋ฆฌํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์†Œ๋“œ
	public static String encrypt(String source) {
		//์•”ํ˜ธํ™” ์ฒ˜๋ฆฌ๋œ ๋ฌธ์ž์—ด์„ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ๋ณ€์ˆ˜ ์„ ์–ธ
		String password="";
		try {
			//MessageDigest ๊ฐ์ฒด : ์•”ํ˜ธํ™” ์ฒ˜๋ฆฌ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋Š” ๊ฐ์ฒด
			//MessageDigest.getInstance(String algorithm) : ๋งค๊ฐœ๋ณ€์ˆ˜์— ์ €์žฅ๋œ ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์ €์žฅ๋œ MessageDigest ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์†Œ๋“œ
			//โ†’ ๋งค๊ฐœ๋ณ€์ˆ˜์— ์ž˜๋ชป๋œ ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ „๋‹ฌํ•  ๊ฒฝ์šฐ NoSuchAlgorithmException ๋ฐœ์ƒ
			//๋‹จ๋ฐฉํ–ฅ ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜ : MD5, SHA-1, SHA-256(๊ถŒ์žฅ), SHA-512 ๋“ฑ
			//์–‘๋ฐฉํ–ฅ ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜ : AES-123, RSA ๋“ฑ
			MessageDigest messageDigest=MessageDigest.getInstance("SHA-256");
			//
			//MessageDigest.update(byte[] input) : MessageDigest ๊ฐ์ฒด์— ์•”ํ˜ธํ™” ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๊ฐ’(byte ๋ฐฐ์—ด)์„ ์ „๋‹ฌ๋ฐ›์•„ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ๋ฉ”์†Œ๋“œ
			//String.getBytes() : String ๊ฐ์ฒด์— ์ €์žฅ๋œ ๋ฌธ์ž์—ด์„ ์›์‹œ๋ฐ์ดํ„ฐ(byte ๋ฐฐ์—ด)๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์†Œ๋“œ
			messageDigest.update(source.getBytes());
			//
			//MessageDigest.digest() : MessageDigest ๊ฐ์ฒด์— ์ €์žฅ๋œ ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ์›์‹œ๋ฐ์ดํ„ฐ๋ฅผ ์•”ํ˜ธํ™” ์ฒ˜๋ฆฌํ•˜์—ฌ byte ๋ฐฐ์—ด๋กœ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์†Œ๋“œ
			byte[] digest=messageDigest.digest();
			//
			//์•”ํ˜ธํ™” ์ฒ˜๋ฆฌ๋œ byte ๋ฐฐ์—ด์„ ๋ฌธ์ž์—ด(String ๊ฐ์ฒด)๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์ €์žฅ
			for(int i=0;i<digest.length;i++) {
				//Integer.toHexString(int i) : ์ •์ˆ˜๊ฐ’์„ ์ „๋‹ฌ๋ฐ›์•„ 16์ง„์ˆ˜์˜ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•˜๋Š ๋ฉ”์†Œ๋“œ
				password+=Integer.toHexString(digest[i]&0xff);
			}
		} catch (NoSuchAlgorithmException e) {
			System.out.println("[์—๋Ÿฌ]์ž˜๋ชป๋œ ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.");
		}
		return password;
	}
}

================================================

๐ŸŒˆPart 6 - ์•„์ด๋”” ์ค‘๋ณต ๊ฒ€์‚ฌ ๊ธฐ๋Šฅ

1. member_join.jsp์˜ ์ฃผ์„๋ฌธ ์ฃผ์„ ํ•ด์ œ ๋ฐ ์ฝ”๋“œ ์ž‘์„ฑ


2. member ํด๋”์— id_check.jsp ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์ž‘์„ฑ

๐Ÿ“ƒid_check.jsp

<%@page import="xyz.itwill.dao.MemberDAO"%>
<%@page import="xyz.itwill.dto.MemberDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- ์•„์ด๋”” ์ „๋‹ฌ๋ฐ›์•„ MEMBER ํ…Œ์ด๋ธ”์— ์ €์žฅ๋œ ๊ธฐ์กด ํšŒ์›์ •๋ณด์˜ ์•„์ด๋””์™€ ๋น„๊ตํ•˜์—ฌ ์ค‘๋ณต ์œ ๋ฌด๋ฅผ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ „๋‹ฌํ•˜๋Š” JSP ๋ฌธ์„œ --%>
<%-- โ†’ ์•„์ด๋”” ๋ฏธ์ค‘๋ณต : ์•„์ด๋”” ์‚ฌ์šฉ ๊ฐ€๋Šฅ ๋ฉ”์„ธ์ง€ - [์•„์ด๋”” ์‚ฌ์šฉ]์„ ํด๋ฆญํ•œ ๊ฒฝ์šฐ ๋ถ€๋ชจ์ฐฝ์˜ ์ž…๋ ฅํƒœ๊ทธ์˜ ์ž…๋ ฅ๊ฐ’ ๋ณ€๊ฒฝ --%>
<%-- โ†’ ์•„์ด๋”” ์ค‘๋ณต : ์•„์ด๋”” ์‚ฌ์šฉ ๋ถˆ๊ฐ€๋Šฅ ๋ฉ”์„ธ์ง€ - ์•„์ด๋””๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ํ˜„์žฌ JSP ๋ฌธ์„œ๋ฅผ ์žฌ์š”์ฒญ --%>
<%
	//๋น„์ •์ƒ์ ์ธ ์š”์ฒญ์— ๋Œ€ํ•œ ์‘๋‹ต ์ฒ˜๋ฆฌ
	if(request.getParameter("id")==null) {
		response.sendError(HttpServletResponse.SC_BAD_REQUEST);
		return;
	}
	//์ „๋‹ฌ๊ฐ’์„ ๋ฐ˜ํ™˜๋ฐ›์•„ ์ €์žฅ
	String id=request.getParameter("id");
	//
	//์•„์ด๋””๋ฅผ ์ „๋‹ฌ๋ฐ›์•„ MEMBER ํ…Œ์ด๋ธ”์— ์ €์žฅ๋œ ํ•ด๋‹น ์•„์ด๋””์˜ ํšŒ์›์ •๋ณด๋ฅผ ๊ฒ€์ƒ‰ํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•˜๋Š” DAO ํด๋ž˜์Šค์˜ ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ
	//โ†’ null ๋ฐ˜ํ™˜ : ์ „๋‹ฌ๋ฐ›์€ ์•„์ด๋””์˜ ํšŒ์›์ •๋ณด๊ฐ€ ๋ฏธ๊ฒ€์ƒ‰ - ์•„์ด๋”” ๋ฏธ์ค‘๋ณต(์•„์ด๋”” ์‚ฌ์šฉ ๊ฐ€๋Šฅ)
	//โ†’ MemberDTO ๊ฐ์ฒด ๋ฐ˜ํ™˜ : ์ „๋‹ฌ๋ฐ›์€ ์•„์ด๋””์˜ ํšŒ์›์ •๋ณด ๊ฒ€์ƒ‰ - ์•„์ด๋”” ์ค‘๋ณต(์•„์ด๋”” ์‚ฌ์šฉ ๋ถˆ๊ฐ€๋Šฅ)
	MemberDTO member=MemberDAO.getDAO().selectMember(id);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
div {
	text-align: center;
	margin: 10px
}
.id {
	font-weight: bold;
	color: red;
}
</style>
</head>
<body>
<% if(member==null) {//์ „๋‹ฌ๋ฐ›์€ ์•„์ด๋””๊ฐ€ ์ค‘๋ณต๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ %>
	<div>์ž…๋ ฅ๋œ <span class="id">[<%=id %>]</span>๋Š” ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์•„์ด๋””์ž…๋‹ˆ๋‹ค.</div>
	<div>
		<button type="button" onclick="selectId();">์•„์ด๋”” ์‚ฌ์šฉ</button>
	</div>
	//
	<script type="text/javascript">
	function selectId() {
		//opener : ํŒ์—…์ฐฝ์„ ์‹คํ–‰ํ•œ ๋ถ€๋ชจ์ฐฝ์„ ํ‘œํ˜„ํ•˜๋Š” ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๊ฐ์ฒด
		opener.join.id.value="<%=id%>";//์ž…๋ ฅํƒœ๊ทธ(์•„์ด๋””)์˜ ์ž…๋ ฅ๊ฐ’ ๋ณ€๊ฒฝ
		opener.join.idCheckResult.value="1";//์ž…๋ ฅํƒœ๊ทธ(๊ฒ€์‚ฌ๊ฒฐ๊ณผ)์˜ ์ž…๋ ฅ๊ฐ’ ๋ณ€๊ฒฝ
		window.close();//์ฐฝ๋‹ซ๊ธฐ - ํŒ์—…์ฐฝ ์ข…๋ฃŒ
	}
	</script>
<% } else {//์ „๋‹ฌ๋ฐ›์€ ์•„์ด๋””๊ฐ€ ์ค‘๋ณต๋œ ๊ฒฝ์šฐ %>
	<div>์ž…๋ ฅ๋œ <span class="id">[<%=id %>]</span>๋Š” ์ด๋ฏธ ์‚ฌ์šฉ์ค‘์ธ ์•„์ด๋””์ž…๋‹ˆ๋‹ค.
	<br>๋‹ค๋ฅธ ์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•˜๊ณ  [ํ™•์ธ] ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”.</div>
	<div>
		<%-- form ํƒœ๊ทธ์˜ action ์†์„ฑ์ด ์ƒ๋žต๋œ ๊ฒฝ์šฐ ํ˜„์žฌ ์š”์ฒญ JSP ๋ฌธ์„œ๋ฅผ ์žฌ์š”์ฒญ --%>
		<%-- form ํƒœ๊ทธ์˜ method ์†์„ฑ์ด ์ƒ๋žต๋œ ๊ฒฝ์šฐ [GET] ๋ฐฉ์‹์œผ๋กœ ์š”์ฒญ --%>
		<form name="checkForm">
			<input type="text" name="id">
			<button type="button" onclick="idCheck();">ํ™•์ธ</button>
		</form>
	</div>
	<div id="message" style="color: red;"></div>
	<script type="text/javascript">
	function idCheck() {
		var id=checkForm.id.value;
		if(id=="") {
			document.getElementById("message").innerHTML="์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.";
			return;
		}
		//
		var idReg=/^[a-zA-Z]\w{5,19}$/g;
		if(!idReg.test(id)) {
			document.getElementById("message").innerHTML="์•„์ด๋””๋ฅผ ํ˜•์‹์— ๋งž๊ฒŒ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.";
			return;
		}
		//
		checkForm.submit();
	}
	</script>
<% } %>
</body>
</html>

================================================

๐ŸŒˆPart 6 - ์šฐํŽธ๋ฒˆํ˜ธ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ

1. member_join.jsp ์ฝ”๋“œ ์ˆ˜์ •

2. member ํด๋”์— post_search.jsp ์ƒ์„ฑ ๋ฐ ์ž‘์„ฑ

๐Ÿ“ƒpost_search.jsp

<%@page import="java.util.ArrayList"%>
<%@page import="xyz.itwill.dao.ZipDAO"%>
<%@page import="xyz.itwill.dto.ZipDTO"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ๋™์ด๋ฆ„์„ ์ž…๋ ฅ๋ฐ›์•„ ZIP ํ…Œ์ด๋ธ”์— ์ €์žฅ๋œ ํ•ด๋‹น ๋™์ด๋ฆ„์ด ํฌํ•จ๋œ ์šฐํŽธ๋ฒˆํ˜ธ ๊ด€๋ จ ์ •๋ณด๋ฅผ ๊ฒ€์ƒ‰ํ•˜์—ฌ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ „๋‹ฌํ•˜๋Š” JSP ๋ฌธ์„œ --%>
<%-- โ†’ [๊ธฐ๋ณธ์ฃผ์†Œ]๋ฅผ ํด๋ฆญํ•œ ๊ฒฝ์šฐ ๋ถ€๋ชจ์ฐฝ์˜ ์ž…๋ ฅํƒœ๊ทธ(์šฐํŽธ๋ฒˆํ˜ธ,๊ธฐ๋ณธ์ฃผ์†Œ)์˜ ์ž…๋ ฅ๊ฐ’ ๋ณ€๊ฒฝ --%>
<%
	//์ „๋‹ฌ๊ฐ’์„ ๋ฐ˜ํ™˜๋ฐ›์•„ ์ €์žฅ
	String dong=request.getParameter("dong");
	//
	//๋™์ด๋ฆ„์„ ์ „๋‹ฌ๋ฐ›์•„ ZIP ํ…Œ์ด๋ธ”์—์„œ ํ•ด๋‹น ๋™์ด๋ฆ„์œผ๋กœ ์‹œ์ž‘๋˜๋Š” ์šฐํŽธ๋ฒˆํ˜ธ ๊ด€๋ จ ์ •๋ณด๋ฅผ ๊ฒ€์ƒ‰ํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•˜๋Š” DAO ํด๋ž˜์Šค์˜ ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ
	List<ZipDTO> zipList=new ArrayList<ZipDTO>();
	if(dong!=null) {//์ „๋‹ฌ๊ฐ’์ด ์žˆ๋Š” ๊ฒฝ์šฐ
		zipList=ZipDAO.getDAO().selectZipList(dong);
	} 
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JSP</title>
<style type="text/css">
#search {
	width: 550px;
	margin: 0 auto;
	text-align: center;	
}
table {
	border: 1px solid black;
	border-collapse: collapse;
	margin: 10px;
	font-size: 14px;
}
td {
	border: 1px solid black;
	text-align: center;
}
.zipcode {
	width: 100px;
}
.address {
	width: 400px;
	text-align: left;
	padding: 2px;
}
</style>
</head>
<body>
	<div id="search">
		<form name="postForm">
			๋™์ด๋ฆ„ : <input type="text" name="dong">
			<button type="button" id="searchBtn">์ฃผ์†Œ๊ฒ€์ƒ‰</button>
		</form>
	</div>
	<%-- ๊ฒ€์ƒ‰๋œ ์šฐํŽธ๋ฒˆํ˜ธ ๊ด€๋ จ ์ •๋ณด๋ฅผ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ „๋‹ฌ --%>
	<% if(!zipList.isEmpty()) { //๊ฒ€์ƒ‰๋œ ์šฐํŽธ๋ฒˆํ˜ธ ๊ด€๋ จ ์ •๋ณด๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ%>
	<table>
		<tr>
			<td class="zipcode">์šฐํŽธ๋ฒˆํ˜ธ</td>
			<td class="address" style="text-align: center;">๊ธฐ๋ณธ์ฃผ์†Œ</td>
		</tr>
		<% for(ZipDTO zip:zipList) { %>
		<tr>
			<td class="zipcode"><%=zip.getZipcode() %></td>
			<%-- a ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•˜์—ฌ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ช…๋ น์„ ์ž‘์„ฑํ•  ๊ฒฝ์šฐ ๋ฐ˜๋“œ์‹œ javascript ์ ‘๋‘์‚ฌ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ๋งŒ ์‹คํ–‰ ๊ฐ€๋Šฅ --%>
			<td class="address">
				<a href="javascript:searchPost('<%=zip.getZipcode()%>','<%=zip.getAddress()%>');"><%=zip.getAddress() %>
			</td>
		</tr>
		<% } %>
	</table>
	<% } %>
	<script type="text/javascript">
	postForm.dong.focus();
	//
	document.getElementById("searchBtn").onclick=function() {
		if(postForm.dong.value=="") {
			postForm.dong.focus();
			return;
		}
		//
		postForm.submit();
	}
	function searchPost(code, addr) {
		opener.join.zipcode.value=code;
		opener.join.address1.value=addr;
		window.close();
	}
	</script>
</body>
</html>

๐ŸŽจ๋ฐฉ๋ฒ•1)

โ—ˆ ๊ณต๊ณต๋ฐ์ดํ„ฐ ์ ์šฉ๋ฒ• ํ…Œ์ด๋ธ”์— ์‚ฝ์ž…,์ €์žฅํ•˜๋Š”๋ฒ•
1.csv ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ(๊ฐ•์‚ฌ๋‹˜ ํŒŒ์ผ ์ฐธ๊ณ )

2. SQL Delope์— ํ…Œ์ด๋ธ” ์ƒ์„ฑ

create table zipcode(zipcode varchar2(40),sido varchar2(46)
	,gugun varchar2(40),dong varchar2(40),ri varchar2(45)
	,bldg varchar2(70),bunji varchar2(20),seq varchar2(15));


3. ๋‹ค์šด๋กœ๋“œ ๋ฐ›์€ csv ํŒŒ์ผ ๋ฐ์ดํ„ฐ ์ž„ํฌํŠธ





4. SQL Develope ์•„๋ž˜์ฝ”๋“œ ์ž‘์„ฑ

create table zip(zipcode, dong, address) 
as select zipcode,DONG,SIDO||' '||GUGUN||' '||DONG||' '||RI||' '||BLDG||' '||BUNJI from zipcode;


5. SQL Develop ์•„๋ž˜์ฝ”๋“œ ์ž‘์„ฑ

drop table zipcode purge;


6. ๋™์ž‘ํ™•์ธ

7. DTO ๋งŒ๋“ค๊ธฐ
1. xyz.itwill.dto ํŒจํ‚ค์ง€์— ZipDTO ํด๋ž˜์Šค ์ƒ์„ฑ

๐Ÿ“ƒZipDTO.java

package xyz.itwill.dto;
//
public class ZipDTO {
	private String zipcode;
	private String dong;
	private String address;
	//
	public ZipDTO() {
		// TODO Auto-generated constructor stub
	}
	public String getZipcode() {
		return zipcode;
	}
	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}
	public String getDong() {
		return dong;
	}
	public void setDong(String dong) {
		this.dong = dong;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
}

8. DAO ๋งŒ๋“ค๊ธฐ
1. xyz.itwill.dao ํŒจํ‚ค์ง€์— ZipDAO ํด๋ž˜์Šค ์ƒ์„ฑ

๐Ÿ“ƒZipDAO.java

package xyz.itwill.dao;
//
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
//
import xyz.itwill.dto.ZipDTO;
//
public class ZipDAO extends JdbcDAO {
	private static ZipDAO _dao;
	//
	private ZipDAO() {
		// TODO Auto-generated constructor stub
	}
	//
	static {
		_dao=new ZipDAO();
	}
	//
	public static ZipDAO getDAO() {
		return _dao;
	}
	//
	//๋™์ด๋ฆ„์„ ์ „๋‹ฌ๋ฐ›์•„ ZIP ํ…Œ์ด๋ธ”์—์„œ ํ•ด๋‹น ๋™์ด๋ฆ„์œผ๋กœ ์‹œ์ž‘๋˜๋Š” ์šฐํŽธ๋ฒˆํ˜ธ ๊ด€๋ จ ์ •๋ณด๋ฅผ ๊ฒ€์ƒ‰ํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์†Œ๋“œ
	public List<ZipDTO> selectZipList(String dong) {
		Connection con=null;
		PreparedStatement pstmt=null;
		ResultSet rs=null;
		List<ZipDTO> zipList=new ArrayList<>();
		try {
			con=getConnection();
			//
			String sql="select * from zip where dong like ?||'%' order by zipcode";
			pstmt=con.prepareStatement(sql);
			pstmt.setString(1, dong);
			//
			rs=pstmt.executeQuery();
			//
			while(rs.next()) {
				ZipDTO zip=new ZipDTO();
				zip.setZipcode(rs.getString("zipcode"));
				zip.setDong(rs.getString("dong"));
				zip.setAddress(rs.getString("address"));
				zipList.add(zip);
			}
		} catch (SQLException e) {
			System.out.println("[์—๋Ÿฌ]selectZipList() ๋ฉ”์†Œ๋“œ์˜ SQL ์˜ค๋ฅ˜ = "+e.getMessage());
		} finally {
			close(con, pstmt, rs);
		}
		return zipList;
	}
}

๐ŸŽจ๋ฐฉ๋ฒ•2)

๋‹ค์Œ์—์„œ ์ œ๊ณตํ•˜๋Š” ์šฐํŽธ๋ฒˆํ˜ธ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ(๊ถŒ์žฅ)
1. ์‚ฌ์ดํŠธ ์ ‘์†

2. ์•„๋ž˜์ฝ”๋“œ Member_join.jsp์— ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ

<script src="//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
<script>
$("#postSearch").click(function() {
	new daum.Postcode({
	    oncomplete: function(data) {
	        $("#zipcode").val(data.zonecode);
	        $("#address1").val(data.address);
	    }
	}).open();
});
</script>

0๊ฐœ์˜ ๋Œ“๊ธ€