지구정복

[JSP] 12/29 | 자바빈으로 게시판만들기(기본게시판, 이모티콘있는 게시판, 페이지번호 있는 게시판), JSP 파일업로드(파일업로드, 파일첨부기능있는 게시판만들기) 본문

데이터 엔지니어링 정복/JAVA & JSP

[JSP] 12/29 | 자바빈으로 게시판만들기(기본게시판, 이모티콘있는 게시판, 페이지번호 있는 게시판), JSP 파일업로드(파일업로드, 파일첨부기능있는 게시판만들기)

eeaarrtthh 2020. 12. 29. 17:55
728x90
반응형

어제 게시판 만들기에 이어서 계속

 

<jsp: include
	<jsp:param
	<%@ include
<jsp: forward
	<jsp:param
	ResponseDispatch

<jsp: useBean		beans - TO(VO)		-> model1
	<jsp: setProperty		직접 Java		    jsp(java) -> class
	<jsp: getProperty

1. 객체 
	TO	- 가장 긴 select문 중심
	DAO	- 페이지(SQL)당 1개가 기본

-board_delete1.jsp

<%@page import="model1.BoardDAO"%>
<%@page import="model1.BoardTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%@ page import="model1.BoardTO" %>
<%@ page import="model1.BoardDAO" %>


<%
	request.setCharacterEncoding( "utf-8" );
	BoardTO to = new BoardTO();	

	String seq = request.getParameter( "seq" );
	to.setSeq(seq);
	
	BoardDAO dao = new BoardDAO();
	to = dao.boardDelete(to);
	
	String subject = to.getSubject();
	String writer = to.getWriter();
	
	
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_write.css">

<script type="text/javascript">
	window.onload = function() {
		document.getElementById( 'submit1' ).onclick = function() {
			if( document.dfrm.password.value.trim() == '' ) {
				alert( '비밀번호를 입력해주세요' );
				return false;
			}
			document.dfrm.submit();
		}
	}
</script>

</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<form action="board_delete1_ok.jsp" method="post" name="dfrm">
		<input type="hidden" name="seq" value="<%= seq %>">
		<div class="contents_sub">	
			<!--게시판-->
			<div class="board_write">
				<table>
				<tr>
					<th class="top">글쓴이</th>
					<td class="top" colspan="3"><input type="text" name="writer" value="<%= writer %>" class="board_view_input_mail" maxlength="5" readonly/></td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan="3"><input type="text" name="subject" value="<%= subject %>" class="board_view_input" readonly/></td>
				</tr>
				<tr>
					<th>비밀번호</th>
					<td colspan="3"><input type="password" name="password" value="" class="board_view_input_mail"/></td>
				</tr>
				</table>
			</div>
			
			<div class="btn_area">
				<div class="align_left">
					<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
					<input type="button" value="보기" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_view1.jsp'" />
				</div>
				<div class="align_right">
					<input type="button" id="submit1" value="삭제" class="btn_write btn_txt01" style="cursor: pointer;" />
				</div>
			</div>
			<!--//게시판-->
		</div>
	</form>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-board_modify1.jsp

<%@page import="model1.BoardDAO"%>
<%@page import="model1.BoardTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="model1.BoardTO" %>
<%@ page import="model1.BoardDAO" %>

<%
	request.setCharacterEncoding( "utf-8" );
	BoardTO to = new BoardTO();
	
	String seq = request.getParameter( "seq" );
	to.setSeq(seq);
	
	BoardDAO dao = new BoardDAO();
	
	to = dao.boardModify( to );
	
	String writer = to.getWriter();
	String subject = to.getSubject();
	String content = to.getContent();
	String mail[] = null;
	if ( to.getMail().equals("") ) {
		mail = new String[] { "", "" };
	} else {
		mail = to.getMail().split( "@" );
	}
	
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_write.css">

<script type="text/javascript">
 	window.onload = function() {
 		document.getElementById( 'submit2' ).onclick = function() {
 			if ( document.mfrm.subject.value.trim() == '' ) {
 				alert( '제목을 입력해주세요' );
 				return false;
 			}
 			if ( document.mfrm.password.value.trim() == '' ) {
 				alert( '비밀번호를 입력해주세요' );
 				return false;
 			}
 			if ( document.mfrm.content.value.trim() == '' ) {
 				alert( '내용을 입력해주세요' );
 				return false;
 			}
 			
 			document.mfrm.submit();
 		}
 	}
</script>

</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<form action="board_modify1_ok.jsp" method="post" name="mfrm">
		<input type="hidden" name="seq" value="<%= seq %>">
		<div class="contents_sub">	
			<!--게시판-->
			<div class="board_write">
				<table>
				<tr>
					<th class="top">글쓴이</th>
					<td class="top" colspan="3"><input type="text" name="writer" value="<%= writer %>" class="board_view_input_mail" maxlength="5" readonly/></td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan="3"><input type="text" name="subject" value="<%= subject %>" class="board_view_input" /></td>
				</tr>
				<tr>
					<th>비밀번호</th>
					<td colspan="3"><input type="password" name="password" value="" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>내용</th>
					<td colspan="3"><textarea name="content" class="board_editor_area"><%= content %></textarea></td>
				</tr>
				<tr>
					<th>이메일</th>
					<td colspan="3"><input type="text" name="mail1" value="<%= mail[0] %>" class="board_view_input_mail"/> @ <input type="text" name="mail2" value="<%= mail[1] %>" class="board_view_input_mail"/></td>
				</tr>
				</table>
			</div>
			
			<div class="btn_area">
				<div class="align_left">
					<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
					<input type="button" value="보기" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_view1.jsp?seq=<%=seq %>'" />
				</div>
				<div class="align_right">
					<input type="button" id="submit2" value="수정" class="btn_write btn_txt01" style="cursor: pointer;" />
				</div>
			</div>
			<!--//게시판-->
		</div>
	</form>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-board_delete1_ok.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="model1.BoardTO" %>
<%@ page import="model1.BoardDAO" %>

<%
	request.setCharacterEncoding( "utf-8" );
	BoardTO to = new BoardTO();

	String seq = request.getParameter( "seq" );
	String password = request.getParameter( "password" );
	
	to.setSeq(seq);
	to.setPassword(password);
	
	BoardDAO dao = new BoardDAO();
	int flag = dao.boardDeleteOk(to);
	
	out.println( " <script type='text/javascript'> " );
	if( flag == 0 ) {
		out.println( " alert('글삭제에 성공했습니다.'); " );
		out.println( " location.href='board_list1.jsp;' " );
	} else if ( flag == 1 ) {
		out.println( " alert('비밀번호가 틀립니다.'); " );
		out.println( " history.back(); " );
	} else {
		out.println( " alert('글삭제에 실패했습니다.'); " );
		out.println( " history.back(); " );
	}
	out.println( " </script> " );
	
%>

-board_modify1_ok.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="model1.BoardTO" %>
<%@ page import="model1.BoardDAO" %>

<%
	request.setCharacterEncoding( "utf-8" );
	BoardTO to = new BoardTO();
	String seq = request.getParameter( "seq" );
	String password = request.getParameter( "password" );
	String subject = request.getParameter( "subject" );
	String content = request.getParameter( "content" );
	String mail = "";
	if ( !request.getParameter( "mail1" ).equals("") && !request.getParameter( "mail2" ).equals("") ) {
		mail = request.getParameter( "mail1" ) + "@" + request.getParameter( "mail2" );
	}
	
	to.setSeq(seq);
	to.setPassword(password);
	to.setSubject(subject);
	to.setContent(content);
	to.setMail(mail);
	
	BoardDAO dao = new BoardDAO();
	int flag = dao.boardModifyOk(to);
	
	
	out.println( " <script type='text/javascript'> " );
	if( flag == 0 ) {
		out.println( " alert('글수정에 성공했습니다.'); " );
		out.println( " location.href='board_modify1.jsp?seq=" + seq + "' " );
	} else if ( flag == 1 ) {
		out.println( " alert('비밀번호가 틀립니다.'); " );
		out.println( " history.back(); " );
	} else {
		out.println( " alert('글수정에 실패했습니다.'); " );
		out.println( " history.back(); " );
	}
	out.println( " </script> " );
	
%>

-boardDAO.java

package model1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class BoardDAO {
	private DataSource dataSource;
	
	public BoardDAO() {
		try {
			Context initCtx = new InitialContext();
			Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
			this.dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		} catch (Exception e) {
			System.out.println( "에러: " + e.getMessage() );
		}
	}
	
	//write
	public void boardWrite() {}
	
	//write_ok
	public int boardWriteOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		int flag = 1;
		
		try {
			conn = dataSource.getConnection();
			
			String sql = "insert into board1 values (0, ?, ?, ?, ?, ?, 0, ?, now() )";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSubject() );
			pstmt.setString( 2, to.getWriter() );
			pstmt.setString( 3, to.getMail() );
			pstmt.setString( 4, to.getPassword() );
			pstmt.setString( 5, to.getContent() );
			pstmt.setString( 6, to.getWip() );
			
			int result = pstmt.executeUpdate();
			if ( result == 1 ) {
				//정상일 때
				flag = 0;
			}
		} catch(SQLException e) {
			System.out.println( "error: " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch (SQLException e) {}
			if ( conn != null ) try { conn.close(); } catch (SQLException e) {}
		}
		return flag;
	}
	
	//list
	public ArrayList<BoardTO> boardList() {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		ArrayList<BoardTO> lists = new ArrayList<BoardTO>();
		
		try {
			conn = dataSource.getConnection();
			
			String sql = "select seq, subject, writer, date_format(wdate, '%Y-%m-%d') wdate, hit, datediff(now(), wdate) wgap from board1 order by seq desc";
			pstmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
			rs = pstmt.executeQuery();
			
			while( rs.next() ) {
				BoardTO to = new BoardTO();
				to.setSeq( rs.getString( "seq" ) );
				to.setSubject( rs.getString( "subject" ) );
				to.setWriter( rs.getString( "writer" ) );
				to.setWdate( rs.getString( "wdate" ) );
				to.setHit( rs.getString( "hit" ) );
				to.setWgap( rs.getInt( "wgap" ) );
				
				lists.add( to );
			}
		} catch(SQLException e) {
			System.out.println( "error: " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try {  conn.close(); } catch ( SQLException e ) {}
		}
		return lists;
	}
	
	//view
	public BoardTO boardView( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			//board_view.jsp에 들어오면 조회수 증가를 위한 update문을 사용한다.
			String sql = "update board1 set hit = hit+1 where seq = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			sql = "select subject, writer, mail, wip, wdate, hit, content from board1 where seq = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터를 하나만 가져오니깐 while문 대신 if문을 사용한다.
			if ( rs.next() ) {
				to.setSubject( rs.getString( "subject" ) );
				to.setWriter( rs.getString( "writer" ) );
				to.setMail( rs.getString( "mail" ) );
				to.setWip( rs.getString( "wip" ) );
				to.setWdate( rs.getString( "wdate" ) );
				to.setHit( rs.getString( "hit" ) );
				to.setContent( rs.getString( "content" ).replaceAll( "\n", "<br>") );
			}
			
		} catch (SQLException e) {
			System.out.println( "error: " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try {  conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//delete
	public BoardTO boardDelete( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			String sql = "select subject, writer from board1 where seq = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터를 하나만 가져오니깐 while문 대신 if문을 사용한다.
			if ( rs.next() ) {
				to.setSubject( rs.getString( "subject" ) );
				to.setWriter( rs.getString( "writer" ) );
			}
			
		} catch(SQLException e) {
			System.out.println( "error: " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try {  conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//delete_ok
	public int boardDeleteOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		//정상처리인지 비정상처리인지를 구분하는 변수 -> 결과를 한 군데에서 통합처리하기 위한 변수
		int flag = 2;
		
		try {
			conn = dataSource.getConnection();
			
			//개인의 비밀번호는 db안쪽에서 검색되도록 해야 한다.
			String sql = "delete from board1 where seq = ? and password = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			pstmt.setString( 2, to.getPassword() );
			
			int result = pstmt.executeUpdate();
			
			//seq는 정상적으로 알아서 잘 넘어가기때문에 비밀번호 오류만 잡아준다.
			if ( result == 0 ) {
				//result 0일 때는 비밀번호 오류
				flag = 1;
			} else if ( result == 1 ) {
				//정상일 때
				flag = 0;
			}
		} catch(SQLException e) {
			System.out.println( "error: " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try {  conn.close(); } catch ( SQLException e ) {}
		}
		return flag;
	}
	
	//modify
	public BoardTO boardModify( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			String sql = "select writer, subject, content, mail from board1 where seq = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터를 하나만 가져오니깐 while문 대신 if문을 사용한다.
			if ( rs.next() ) {
				to.setSubject( rs.getString( "subject" ) );
				to.setWriter( rs.getString( "writer" ) );
				to.setContent( rs.getString( "content" ) );
				to.setMail( rs.getString( "mail" ) );
			}

		} catch(SQLException e) {
			System.out.println( "error: " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try {  conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//modify_ok
	public int boardModifyOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		//정상처리인지 비정상처리인지를 구분하는 변수 -> 결과를 한 군데에서 통합처리하기 위한 변수
		int flag = 2;
		
		try {
			conn = dataSource.getConnection();
			
			//개인의 비밀번호는 db안쪽에서 검색되도록 해야 한다.
			String sql = "update board1 set subject = ?, content = ?, mail = ? where seq = ? and password = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSubject() );
			pstmt.setString( 2, to.getContent() );
			pstmt.setString( 3, to.getMail() );
			pstmt.setString( 4, to.getSeq() );
			pstmt.setString( 5, to.getPassword() );
			
			int result = pstmt.executeUpdate();
			
			//seq는 정상적으로 알아서 잘 넘어가기때문에 비밀번호 오류만 잡아준다.
			if ( result == 0 ) {
				//result 0일 때는 비밀번호 오류
				flag = 1;
			} else if ( result == 1 ) {
				//정상일 때
				flag = 0;
			}
			
		} catch(SQLException e) {
			System.out.println( "error: " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try {  conn.close(); } catch ( SQLException e ) {}
		}
		return flag;
	}
}

 

 

ㅇ이모티콘 게시판 자바빈으로 만들기

-BoardDAO.java

package model1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class BoardDAO {
	private DataSource dataSource;
	
	public BoardDAO() {
		try {
			Context initCtx = new InitialContext();
			Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
			this.dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		} catch (NamingException e) {
			System.out.println( "[error] : " + e.getMessage() );
		}
	}
	
	//write
	public void boardWrite() {
		
	}
	
	//write_ok
	public int boardWriteOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		//정상처리 또는 비정상처리 변수
		int flag = 1;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에 데이터 집어넣기
			String sql = "insert into board2 values (0, ?, ?, ?, ?, ?, 0, ?, now(), ?)";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSubject() );
			pstmt.setString( 2, to.getWriter() );
			pstmt.setString( 3, to.getMail() );
			pstmt.setString( 4, to.getPassword() );
			pstmt.setString( 5, to.getContent() );
			pstmt.setString( 6, to.getWip() );
			pstmt.setString( 7, to.getEmot() );
			
			int result = pstmt.executeUpdate();
			if ( result == 1 ) {
				flag = 0;
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return flag;
	}
	
	//list
	public ArrayList<BoardTO> boardList() {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		ArrayList<BoardTO> lists = new ArrayList<BoardTO>();
		
		try {
			conn = dataSource.getConnection();
			
			String sql = "select emot, seq, subject, writer, date_format(wdate, '%Y-%m-%d') wdate, hit, datediff(now(), wdate) wgap from board2 order by seq desc";
			pstmt = conn.prepareStatement( sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 글목록 가져와서 리스트 나타내기
			while( rs.next() ) {
				BoardTO to = new BoardTO();
				String emot = rs.getString( "emot" );
				String seq = rs.getString( "seq" );
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				String wdate = rs.getString( "wdate" );
				String hit = rs.getString( "hit" );
				int wgap = rs.getInt( "wgap" );
				
				to.setEmot(emot);
				to.setSeq(seq);
				to.setSubject(subject);
				to.setWriter(writer);
				to.setWdate(wdate);
				to.setHit(hit);
				to.setWgap(wgap);
				
				lists.add( to );
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return lists;
	}
	
	//view
	public BoardTO boardView( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			//조회수 증가시키기
			String sql = "update board2 set hit = hit+1 where seq = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 해당 글 내용 가져오기
			sql = "select subject, writer, mail, content, hit, wip, wdate, emot from board2 where seq = ?";
			pstmt = conn.prepareStatement( sql );
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 sql실행문의 각 컬럼을 가져와서 변수에 저장
			if ( rs.next() ) {
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				String mail = rs.getString( "mail" );
				String content = rs.getString( "content" );
				String hit = rs.getString( "hit" );
				String wip = rs.getString( "wip" );
				String wdate = rs.getString( "wdate" );
				String emot = rs.getString( "emot" );
				
				to.setSubject(subject);
				to.setWriter(writer);
				to.setMail(mail);
				to.setContent(content);
				to.setHit(hit);
				to.setWip(wip);
				to.setWdate(wdate);
				to.setEmot(emot);
			}
		
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//delete
	public BoardTO boardDelete( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에서 해당 글 내용 가져오기
			String sql = "select subject, writer from board2 where seq = ?";
			pstmt = conn.prepareStatement( sql );
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 sql실행문의 각 컬럼을 가져와서 변수에 저장
			if ( rs.next() ) {
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				
				to.setSubject(subject);
				to.setWriter(writer);
			}
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//delete_ok
	public int boardDeleteOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		int flag = 2;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에서 해당 글 내용 가져오기
			String sql = "delete from board2 where seq = ? and password = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			pstmt.setString( 2, to.getPassword() );
			
			int result = pstmt.executeUpdate();
			if ( result == 0 ) {
				flag = 1;
			} else if ( result ==1 ) {
				flag = 0;
			}
		
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return flag;
	}
	
	//modify
	public BoardTO boardModify( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에서 해당 글 내용 가져오기
			String sql = "select writer, subject, content, mail, emot from board2 where seq = ?";
			pstmt = conn.prepareStatement( sql );
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 sql실행문의 각 컬럼을 가져와서 변수에 저장
			if ( rs.next() ) {
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				String content = rs.getString( "content" );
				String mail = rs.getString( "mail" );
				String emot = rs.getString( "emot" );
				
				to.setSubject(subject);
				to.setWriter(writer);
				to.setContent(content);
				to.setMail(mail);
				to.setEmot(emot);
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//modify_ok
	public int boardModifyOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		int flag = 2;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에서 해당 글 내용 가져오기
			String sql = "update board2 set subject = ?, content = ?, mail = ?, emot = ? where seq = ? and password = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSubject() );
			pstmt.setString( 2, to.getContent() );
			pstmt.setString( 3, to.getMail() );
			pstmt.setString( 4, to.getEmot() );
			pstmt.setString( 5, to.getSeq() );
			pstmt.setString( 6, to.getPassword() );
			
			int result = pstmt.executeUpdate();
			if ( result == 0 ) {
				flag = 1;
			} else if ( result ==1 ) {
				flag = 0;
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return flag;
	}
}

-BoardTO.java

package model1;

public class BoardTO {
	private String seq;
	private String subject;
	private String writer;
	private String mail;
	private String password;
	private String content;
	private String hit;
	private String wip;
	private String wdate;
	private String emot;
	private int wgap;
	
	public String getSeq() {
		return seq;
	}
	public String getSubject() {
		return subject;
	}
	public String getWriter() {
		return writer;
	}
	public String getMail() {
		return mail;
	}
	public String getPassword() {
		return password;
	}
	public String getContent() {
		return content;
	}
	public String getHit() {
		return hit;
	}
	public String getWip() {
		return wip;
	}
	public String getWdate() {
		return wdate;
	}
	public String getEmot() {
		return emot;
	}
	public int getWgap() {
		return wgap;
	}
	
	public void setSeq(String seq) {
		this.seq = seq;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public void setWriter(String writer) {
		this.writer = writer;
	}
	public void setMail(String mail) {
		this.mail = mail;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public void setHit(String hit) {
		this.hit = hit;
	}
	public void setWip(String wip) {
		this.wip = wip;
	}
	public void setWdate(String wdate) {
		this.wdate = wdate;
	}
	public void setEmot(String emot) {
		this.emot = emot;
	}
	public void setWgap(int wgap) {
		this.wgap = wgap;
	}
}

-Board_list1.jsp

<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%@ page import="model1.BoardDAO" %>
<%@ page import="model1.BoardTO" %>


<%
	BoardDAO dao = new BoardDAO();
	ArrayList<BoardTO> lists = dao.boardList();
	int totalRecord = lists.size();
	StringBuffer sbHtml = new StringBuffer();
	
	for ( BoardTO to : lists ) {
		sbHtml.append(" <tr> ");
		sbHtml.append(" 	<td><img src='../../images/emoticon/" + to.getEmot() + ".png' width='15'/></td> ");
		sbHtml.append(" 	<td>" + to.getSeq() + "</td> ");
		sbHtml.append( "	<td class='left'> ");
		sbHtml.append( "		<a href='board_view1.jsp?seq=" + to.getSeq() + "'>" + to.getSubject() + "</a>&nbsp; ");
		if( to.getWgap() == 0 ) {
			sbHtml.append( "		<img src='../../images/icon_hot.gif' alt='HOT'> ");
		}
		sbHtml.append( "	</td> " );
		sbHtml.append( " 	<td>" + to.getWriter() + "</td> " );
		sbHtml.append( " 	<td>" + to.getWdate() + "</td> " );
		sbHtml.append( " 	<td>" + to.getHit() + "</td> " );
		sbHtml.append( " 	<td>&nbsp;</td> " );
		sbHtml.append( " </tr> " );
	}
	
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_list.css">
</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<div class="contents_sub">
		<div class="board_top">
			<div class="bold">총 <span class="txt_orange"><%= totalRecord %></span>건</div>
		</div>

		<!--게시판-->
		<div class="board">
			<table>
			<tr>
				<th width="3%">&nbsp;</th>
				<th width="5%">번호</th>
				<th>제목</th>
				<th width="10%">글쓴이</th>
				<th width="17%">등록일</th>
				<th width="5%">조회</th>
				<th width="3%">&nbsp;</th>
			</tr>
			<%= sbHtml %>
			</table>
		</div>	
		<div class="align_right">
			<input type="button" value="쓰기" class="btn_write btn_txt01" style="cursor: pointer;" onclick="location.href='board_write1.jsp'" />
		</div>
		<!--//게시판-->
	</div>
</div>
<!--//하단 디자인 -->

</body>
</html>

-Board_write1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_write.css">

<script type="text/javascript">
	window.onload = function() {
		document.getElementById( 'submit1' ).onclick = function() {
			if ( document.wfrm.info.checked == false ) {
				alert( '개인정보 동의를 해주세요' );
				return false;
			}
			if ( document.wfrm.writer.value.trim() == '' ) {
				alert( '글쓴이를 입력해주세요' );
				return false;
			}
			if ( document.wfrm.subject.value.trim() == '' ) {
				alert( '제목을 입력해주세요' );
				return false;
			}
			if ( document.wfrm.password.value.trim() == '' ) {
				alert( '비밀번호를 입력해주세요' );
				return false;
			}

			document.wfrm.submit();
		}
	}
</script>

</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<form action="board_write1_ok.jsp" method="post" name="wfrm">
		<div class="contents_sub">	
			<!--게시판-->
			<div class="board_write">
				<table>
				<tr>
					<th class="top">글쓴이</th>
					<td class="top" colspan="3"><input type="text" name="writer" value="" class="board_view_input_mail" maxlength="5" /></td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan="3"><input type="text" name="subject" value="" class="board_view_input" /></td>
				</tr>
				<tr>
					<th>비밀번호</th>
					<td colspan="3"><input type="password" name="password" value="" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>내용</th>
					<td colspan="3"><textarea name="content" class="board_editor_area"></textarea></td>
				</tr>
				<tr>
					<th>이메일</th>
					<td colspan="3"><input type="text" name="mail1" value="" class="board_view_input_mail"/> @ <input type="text" name="mail2" value="" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>이모티콘</th>
					<td colspan="3" align="center">
						<table>
						<tr>
							<td>
								<img src="../../images/emoticon/emot01.png" width="25"/><br />
								<input type="radio" name="emot" value="emot01" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot02.png" width="25" /><br />
								<input type="radio" name="emot" value="emot02" class="input_radio" checked="checked"/>
							</td>
							<td>
								<img src="../../images/emoticon/emot03.png" width="25" /><br />
								<input type="radio" name="emot" value="emot03" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot04.png" width="25" /><br />
								<input type="radio" name="emot" value="emot04" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot05.png" width="25" /><br />
								<input type="radio" name="emot" value="emot05" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot06.png" width="25" /><br />
								<input type="radio" name="emot" value="emot06" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot07.png" width="25" /><br />
								<input type="radio" name="emot" value="emot07" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot08.png" width="25" /><br />
								<input type="radio" name="emot" value="emot08" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot09.png" width="25" /><br />
								<input type="radio" name="emot" value="emot09" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot10.png" width="25" /><br />
								<input type="radio" name="emot" value="emot10" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot11.png" width="25"/><br />
								<input type="radio" name="emot" value="emot11" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot12.png" width="25" /><br />
								<input type="radio" name="emot" value="emot12" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot13.png" width="25" /><br />
								<input type="radio" name="emot" value="emot13" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot14.png" width="25" /><br />
								<input type="radio" name="emot" value="emot14" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot15.png" width="25" /><br />
								<input type="radio" name="emot" value="emot15" class="input_radio" />
							</td>
						</tr>
						<tr>
							<td>
								<img src="../../images/emoticon/emot16.png" width="25"/><br />
								<input type="radio" name="emot" value="emot16" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot17.png" width="25" /><br />
								<input type="radio" name="emot" value="emot17" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot18.png" width="25" /><br />
								<input type="radio" name="emot" value="emot18" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot19.png" width="25" /><br />
								<input type="radio" name="emot" value="emot19" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot20.png" width="25" /><br />
								<input type="radio" name="emot" value="emot20" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot21.png" width="25" /><br />
								<input type="radio" name="emot" value="emot21" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot22.png" width="25" /><br />
								<input type="radio" name="emot" value="emot22" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot23.png" width="25" /><br />
								<input type="radio" name="emot" value="emot23" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot24.png" width="25" /><br />
								<input type="radio" name="emot" value="emot24" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot25.png" width="25"/><br />
								<input type="radio" name="emot" value="emot25" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot26.png" width="25" /><br />
								<input type="radio" name="emot" value="emot26" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot27.png" width="25" /><br />
								<input type="radio" name="emot" value="emot27" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot28.png" width="25" /><br />
								<input type="radio" name="emot" value="emot28" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot29.png" width="25" /><br />
								<input type="radio" name="emot" value="emot29" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot30.png" width="25" /><br />
								<input type="radio" name="emot" value="emot30" class="input_radio" />
							</td>
						</tr>
						<tr>
							<td>
								<img src="../../images/emoticon/emot31.png" width="25"/><br />
								<input type="radio" name="emot" value="emot31" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot32.png" width="25" /><br />
								<input type="radio" name="emot" value="emot32" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot33.png" width="25" /><br />
								<input type="radio" name="emot" value="emot33" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot34.png" width="25" /><br />
								<input type="radio" name="emot" value="emot34" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot35.png" width="25" /><br />
								<input type="radio" name="emot" value="emot35" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot36.png" width="25" /><br />
								<input type="radio" name="emot" value="emot36" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot37.png" width="25" /><br />
								<input type="radio" name="emot" value="emot37" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot38.png" width="25" /><br />
								<input type="radio" name="emot" value="emot38" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot39.png" width="25" /><br />
								<input type="radio" name="emot" value="emot39" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot40.png" width="25"/><br />
								<input type="radio" name="emot" value="emot40" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot41.png" width="25" /><br />
								<input type="radio" name="emot" value="emot41" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot42.png" width="25" /><br />
								<input type="radio" name="emot" value="emot42" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot43.png" width="25" /><br />
								<input type="radio" name="emot" value="emot43" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot44.png" width="25" /><br />
								<input type="radio" name="emot" value="emot44" class="input_radio" />
							</td>
							<td>
								<img src="../../images/emoticon/emot45.png" width="25" /><br />
								<input type="radio" name="emot" value="emot45" class="input_radio" />
							</td>
						</tr>
						</table>
					</td>
				</tr>
				</table>
				
				<table>
				<tr>
					<br />
					<td style="text-align:left;border:1px solid #e0e0e0;background-color:f9f9f9;padding:5px">
						<div style="padding-top:7px;padding-bottom:5px;font-weight:bold;padding-left:7px;font-family: Gulim,Tahoma,verdana;">※ 개인정보 수집 및 이용에 관한 안내</div>
						<div style="padding-left:10px;">
							<div style="width:97%;height:95px;font-size:11px;letter-spacing: -0.1em;border:1px solid #c5c5c5;background-color:#fff;padding-left:14px;padding-top:7px;">
								1. 수집 개인정보 항목 : 회사명, 담당자명, 메일 주소, 전화번호, 홈페이지 주소, 팩스번호, 주소 <br />
								2. 개인정보의 수집 및 이용목적 : 제휴신청에 따른 본인확인 및 원활한 의사소통 경로 확보 <br />
								3. 개인정보의 이용기간 : 모든 검토가 완료된 후 3개월간 이용자의 조회를 위하여 보관하며, 이후 해당정보를 지체 없이 파기합니다. <br />
								4. 그 밖의 사항은 개인정보취급방침을 준수합니다.
							</div>
						</div>
						<div style="padding-top:7px;padding-left:5px;padding-bottom:7px;font-family: Gulim,Tahoma,verdana;">
							<input type="checkbox" name="info" value="1" class="input_radio"> 개인정보 수집 및 이용에 대해 동의합니다.
						</div>
					</td>
				</tr>
				</table>
			</div>
			
			<div class="btn_area">
				<div class="align_left">
					<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
				</div>
				<div class="align_right">
					<input type="button" id="submit1" value="쓰기" class="btn_write btn_txt01" style="cursor: pointer;" />
				</div>
			</div>
			<!--//게시판-->
		</div>
	</form>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-Board_write1_ok.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="model1.BoardDAO" %>
<%@ page import="model1.BoardTO" %>

<%
	request.setCharacterEncoding( "utf-8" );
	BoardTO to = new BoardTO();

	String writer = request.getParameter( "writer" );
	String subject = request.getParameter( "subject" );
	String password = request.getParameter( "password" );
	String content = request.getParameter( "content" );
	String mail = "";
	if ( !request.getParameter( "mail1" ).equals("")  && !request.getParameter( "mail2" ).equals("") ) {
		mail = request.getParameter( "mail1" ) + "@" + request.getParameter( "mail2" );
	}
	String wip = request.getRemoteAddr();
	String emot = request.getParameter( "emot" );
	
	to.setWriter(writer);
	to.setSubject(subject);
	to.setPassword(password);
	to.setContent(content);
	to.setMail(mail);
	to.setWip(wip);
	to.setEmot(emot);
	
	BoardDAO dao = new BoardDAO();
	int flag = dao.boardWriteOk( to );
	
	out.println(" <script type='text/javascript'> ");
	if ( flag == 0 ) {
		out.println(" alert( '글쓰기에 성공했습니다.' ); ");
		out.println(" location.href='board_list1.jsp;' ");
	} else {
		out.println(" alert( '글쓰기에 실패했습니다.' ); ");
		out.println(" history.back(); ");
	}
	
	out.println(" </script> ");
	
%>

-Board_view1.jsp

<%@page import="model1.BoardDAO"%>
<%@page import="model1.BoardTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.sql.DataSource" %>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>

<%
	request.setCharacterEncoding( "utf-8" );
	
	String seq = request.getParameter( "seq" );
	BoardTO to = new BoardTO();
	to.setSeq(seq);
	
	BoardDAO dao = new BoardDAO();
	to = dao.boardView(to);
	
	String subject = to.getSubject();
	String writer = to.getWriter();
	String mail = to.getMail();
	String content = to.getContent();
	String hit = to.getHit();
	String wip = to.getWip();
	String wdate = to.getWdate();
	String emot = to.getEmot();

%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_view.css">
</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<div class="contents_sub">
		<!--게시판-->
		<div class="board_view">
			<table>
			<tr>
				<th width="10%">제목</th>
				<td width="60%">(<img src="../../images/emoticon/<%=emot %>.png" width="15"/>)&nbsp;<%=subject %></td>
				<th width="10%">등록일</th>
				<td width="20%"><%=wdate %></td>
			</tr>
			<tr>
				<th>글쓴이</th>
				<td><%=writer %>(<%=mail %>)(<%=wip %>)</td>
				<th>조회</th>
				<td><%=hit %></td>
			</tr>
			<tr>
				<td colspan="4" height="200" valign="top" style="padding: 20px; line-height: 160%"><%= content %></td>
			</tr>
			</table>
		</div>

		<div class="btn_area">
			<div class="align_left">
				<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
			</div>
			<div class="align_right">
				<input type="button" value="수정" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_modify1.jsp?seq=<%=seq %>'" />
				<input type="button" value="삭제" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_delete1.jsp?seq=<%=seq %>'" />
				<input type="button" value="쓰기" class="btn_write btn_txt01" style="cursor: pointer;" onclick="location.href='board_write1.jsp'" />
			</div>
		</div>	
		<!--//게시판-->
	</div>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-Board_delete1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="model1.BoardDAO" %>
<%@ page import="model1.BoardTO" %>

<%
	request.setCharacterEncoding( "utf-8" );
	String seq = request.getParameter( "seq" );

	BoardTO to = new BoardTO();
	to.setSeq(seq);
	
	BoardDAO dao = new BoardDAO();
	to = dao.boardDelete(to);
	
	String subject = to.getSubject();
	String writer = to.getWriter();
	
	
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_write.css">

<script type="text/javascript">
	window.onload = function() {
		document.getElementById('submit1').onclick = function() {
			if ( document.dfrm.password.value.trim() == '' ) {
				alert('비밀번호를 입력해주세요.');
				return false;
			}
			document.dfrm.submit();
		}
	}
</script>

</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<form action="board_delete1_ok.jsp" method="post" name="dfrm">
		<input type="hidden" name="seq" value="<%=seq%>">
		<div class="contents_sub">	
			<!--게시판-->
			<div class="board_write">
				<table>
				<tr>
					<th class="top">글쓴이</th>
					<td class="top" colspan="3"><input type="text" name="writer" value="<%=writer %>" class="board_view_input_mail" maxlength="5" readonly/></td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan="3"><input type="text" name="subject" value="<%=subject %>" class="board_view_input" readonly/></td>
				</tr>
				<tr>
					<th>비밀번호</th>
					<td colspan="3"><input type="password" name="password" value="" class="board_view_input_mail"/></td>
				</tr>
				</table>
			</div>
			
			<div class="btn_area">
				<div class="align_left">
					<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
					<input type="button" value="보기" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_view1.jsp?seq=<%=seq %>'" />
				</div>
				<div class="align_right">
					<input type="button" id="submit1" value="삭제" class="btn_write btn_txt01" style="cursor: pointer;" />
				</div>
			</div>
			<!--//게시판-->
		</div>
	</form>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-Board_delete1_ok.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="model1.BoardDAO" %>
<%@ page import="model1.BoardTO" %>

<%
	request.setCharacterEncoding( "utf-8" );

	String seq = request.getParameter( "seq" );
	String password = request.getParameter( "password" );
	
	BoardTO to = new BoardTO();
	to.setSeq(seq);
	to.setPassword(password);
	
	BoardDAO dao = new BoardDAO();
	
	int flag = dao.boardDeleteOk(to);
	
	
	out.println(" <script type='text/javascript'> ");
	if ( flag == 0 ) {
		out.println(" alert( '글삭제에 성공했습니다.' ); ");
		out.println(" location.href='board_list1.jsp;' ");
	} else if ( flag == 1 ) {
		out.println(" alert( '비밀번호가 틀립니다.' ); ");
		out.println(" history.back(); ");
	} else {
		out.println(" alert( '글삭제에 실패했습니다.' ); ");
		out.println(" history.back(); ");
	}
	
	out.println(" </script> ");
	
%>

-Board_modify1.jsp

<%@page import="model1.BoardDAO"%>
<%@page import="model1.BoardTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%@ page import="model1.BoardDAO" %>
<%@ page import="model1.BoardTO" %>

<%
	request.setCharacterEncoding( "utf-8" );
	String seq = request.getParameter( "seq" );
	
	BoardTO to = new BoardTO();
	to.setSeq(seq);
	
	BoardDAO dao = new BoardDAO();
	to = dao.boardModify(to);
	
	String subject = to.getSubject();
	String writer = to.getWriter();
	String content = to.getContent();
	String mail[] = null;
	if ( to.getMail().equals("") ) {
		mail = new String[] {"", ""};
	} else {
		mail = to.getMail().split("@");
	}
	String emot = to.getEmot();
	
	StringBuffer sbEmot = new StringBuffer();
	
	for ( int row=1, i=1; row<=3; row++ ) {
		sbEmot.append(" <tr> ");
		for ( int col=1; col<=15; col++ ) {
			sbEmot.append(" 	<td> ");
			if ( i <= 9 ) {
				if ( emot.equals( "emot0"+i ) ) {
					sbEmot.append(" 		<img src='../../images/emoticon/emot0" + i +".png' width='25'/> ");
					sbEmot.append(" 		<input type='radio' name='emot' value='emot0" + i + "' class='input_radio' checked='checked' /> ");
				} else {
					sbEmot.append(" 		<img src='../../images/emoticon/emot0" + i +".png' width='25'/> ");
					sbEmot.append(" 		<input type='radio' name='emot' value='emot0" + i + "' class='input_radio' /> ");
				}
			} else {
				if ( emot.equals( "emot"+i ) ) {
					sbEmot.append(" 		<img src='../../images/emoticon/emot" + i +".png' width='25'/> ");
					sbEmot.append(" 		<input type='radio' name='emot' value='emot" + i + "' class='input_radio' checked='checked' /> ");
				} else {
					sbEmot.append(" 		<img src='../../images/emoticon/emot" + i +".png' width='25'/> ");
					sbEmot.append(" 		<input type='radio' name='emot' value='emot" + i + "' class='input_radio' /> ");
				}
			}
			sbEmot.append(" 	</td> ");
			i++;
		}
		sbEmot.append(" </tr> ");
	}
	
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_write.css">

<script type="text/javascript">
	window.onload = function() {
		document.getElementById('submit1').onclick = function() {
			if ( document.mfrm.subject.value.trim() == '' ) {
				alert( '제목을 입력해주세요.' );
				return false;
			}
			if ( document.mfrm.password.value.trim() == '' ) {
				alert( '비밀번호를 입력해주세요.' );
				return false;
			}
			if ( document.mfrm.content.value.trim() == '' ) {
				alert( '내용을 입력해주세요.' );
				return false;
			}
			document.mfrm.submit();
		}
	}
</script>

</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<form action="board_modify1_ok.jsp" method="post" name="mfrm">
		<input type="hidden" name="seq" value="<%= seq%>">
		<div class="contents_sub">	
			<!--게시판-->
			<div class="board_write">
				<table>
				<tr>
					<th class="top">글쓴이</th>
					<td class="top" colspan="3"><input type="text" name="writer" value="<%=writer %>" class="board_view_input_mail" maxlength="5" readonly/></td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan="3"><input type="text" name="subject" value="<%=subject %>" class="board_view_input" /></td>
				</tr>
				<tr>
					<th>비밀번호</th>
					<td colspan="3"><input type="password" name="password" value="" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>내용</th>
					<td colspan="3"><textarea name="content" class="board_editor_area"><%=content %></textarea></td>
				</tr>
				<tr>
					<th>이메일</th>
					<td colspan="3"><input type="text" name="mail1" value="<%=mail[0] %>" class="board_view_input_mail"/> @ <input type="text" name="mail2" value="<%=mail[1] %>" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>이모티콘</th>
					<td colspan="3" align="center">
						<table>
						<%=sbEmot %>
						
						</table>
					</td>
				</tr>
				</table>
			</div>
			
			<div class="btn_area">
				<div class="align_left">
					<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
					<input type="button" value="보기" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_view1.jsp?seq=<%=seq %>'" />
				</div>
				<div class="align_right">
					<input type="button" id="submit1" value="수정" class="btn_write btn_txt01" style="cursor: pointer;" />
				</div>
			</div>
			<!--//게시판-->
		</div>
	</form>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-Board_modify1_ok.jsp

<%@page import="model1.BoardTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="model1.BoardDAO" %>
<%@ page import="model1.BoardTO" %>

<%
	request.setCharacterEncoding( "utf-8" );
	BoardTO to = new BoardTO();
	
	String seq = request.getParameter( "seq" );
	String password = request.getParameter( "password" );
	String subject = request.getParameter( "subject" );
	String content = request.getParameter( "content" );
	String mail = "";
	if ( !request.getParameter( "mail1" ).equals("") && !request.getParameter( "mail2" ).equals("") ) {
		mail = request.getParameter( "mail1" ) + "@" + request.getParameter( "mail2" );
	}
	
	String emot = request.getParameter( "emot" );
	
	to.setSeq(seq);
	to.setPassword(password);
	to.setSubject(subject);
	to.setContent(content);
	to.setMail(mail);
	to.setEmot(emot);
	
	BoardDAO dao = new BoardDAO();
	
	int flag = dao.boardModifyOk(to);
	
	out.println(" <script type='text/javascript'> ");
	if ( flag == 0 ) {
		out.println(" alert( '글수정에 성공했습니다.' ); ");
		out.println(" location.href='board_list1.jsp?seq="+seq+"' ");
	} else if ( flag == 1 ) {
		out.println(" alert( '비밀번호가 틀립니다.' ); ");
		out.println(" history.back(); ");
	} else {
		out.println(" alert( '글수정에 실패했습니다.' ); ");
		out.println(" history.back(); ");
	}
	out.println(" </script> ");
	
%>

 

ㅇ페이지번호 있는 게시판 만들기

-BoardListTO => 페이지처리를 위한 TO

package model1;

import java.util.ArrayList;

public class BoardListTO {
	private int cpage;
	private int recordPerPage;
	private int blockPerPage;
	private int totalPage;
	private int totalRecord;
	private int startBlock;
	private int endBlock;
	private int blockRecord;
	private ArrayList<BoardTO> boardLists;
	
	public BoardListTO() {
		this.cpage = 1;
		this.recordPerPage = 10;
		this.blockPerPage = 5;
		this.totalPage = 1;
		this.totalRecord = 0;
		this.blockRecord = 0;
	}
	
	public int getBlockRecord() {
		return blockRecord;
	}
	public int getCpage() {
		return cpage;
	}
	public int getRecordPerPage() {
		return recordPerPage;
	}
	public int getBlockPerPage() {
		return blockPerPage;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public int getTotalRecord() {
		return totalRecord;
	}
	public int getStartBlock() {
		return startBlock;
	}
	public int getEndBlock() {
		return endBlock;
	}
	public ArrayList<BoardTO> getBoardLists() {
		return boardLists;
	}

	public void setCpage(int cpage) {
		this.cpage = cpage;
	}
	public void setRecordPerPage(int recordPerPage) {
		this.recordPerPage = recordPerPage;
	}
	public void setBlockPerPage(int blockPerPage) {
		this.blockPerPage = blockPerPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public void setTotalRecord(int totalRecord) {
		this.totalRecord = totalRecord;
	}
	public void setStartBlock(int startBlock) {
		this.startBlock = startBlock;
	}
	public void setEndBlock(int endBlock) {
		this.endBlock = endBlock;
	}
	public void setBlockRecord(int blockRecord) {
		this.blockRecord = blockRecord;
	}
	public void setBoardLists(ArrayList<BoardTO> boardLists) {
		this.boardLists = boardLists;
	}

}

-BoardTO

package model1;

public class BoardTO {
	private String seq;
	private String subject;
	private String writer;
	private String mail;
	private String password;
	private String content;
	private String hit;
	private String wip;
	private String wdate;
	private String emot;
	private int wgap;
	
	public String getSeq() {
		return seq;
	}
	public String getSubject() {
		return subject;
	}
	public String getWriter() {
		return writer;
	}
	public String getMail() {
		return mail;
	}
	public String getPassword() {
		return password;
	}
	public String getContent() {
		return content;
	}
	public String getHit() {
		return hit;
	}
	public String getWip() {
		return wip;
	}
	public String getWdate() {
		return wdate;
	}
	public String getEmot() {
		return emot;
	}
	public int getWgap() {
		return wgap;
	}
	
	public void setSeq(String seq) {
		this.seq = seq;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public void setWriter(String writer) {
		this.writer = writer;
	}
	public void setMail(String mail) {
		this.mail = mail;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public void setHit(String hit) {
		this.hit = hit;
	}
	public void setWip(String wip) {
		this.wip = wip;
	}
	public void setWdate(String wdate) {
		this.wdate = wdate;
	}
	public void setEmot(String emot) {
		this.emot = emot;
	}
	public void setWgap(int wgap) {
		this.wgap = wgap;
	}
}

-BoardDAO

package model1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class BoardDAO {
	private DataSource dataSource;
	
	public BoardDAO() {
		try {
			Context initCtx = new InitialContext();
			Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
			this.dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		} catch (NamingException e) {
			System.out.println( "[error] : " + e.getMessage() );
		}
	}
	
	//write
	public void boardWrite() {
		
	}
	
	//write_ok
	public int boardWriteOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		//정상처리 또는 비정상처리 변수
		int flag = 1;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에 데이터 집어넣기
			String sql = "insert into board2 values (0, ?, ?, ?, ?, ?, 0, ?, now(), ?)";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSubject() );
			pstmt.setString( 2, to.getWriter() );
			pstmt.setString( 3, to.getMail() );
			pstmt.setString( 4, to.getPassword() );
			pstmt.setString( 5, to.getContent() );
			pstmt.setString( 6, to.getWip() );
			pstmt.setString( 7, to.getEmot() );
			
			int result = pstmt.executeUpdate();
			if ( result == 1 ) {
				flag = 0;
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return flag;
	}
	
	//list
	public ArrayList<BoardTO> boardList() {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		ArrayList<BoardTO> lists = new ArrayList<BoardTO>();
		
		try {
			conn = dataSource.getConnection();
			
			String sql = "select emot, seq, subject, writer, date_format(wdate, '%Y-%m-%d') wdate, hit, datediff(now(), wdate) wgap from board2 order by seq desc";
			pstmt = conn.prepareStatement( sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 글목록 가져와서 리스트 나타내기
			while( rs.next() ) {
				BoardTO to = new BoardTO();
				String emot = rs.getString( "emot" );
				String seq = rs.getString( "seq" );
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				String wdate = rs.getString( "wdate" );
				String hit = rs.getString( "hit" );
				int wgap = rs.getInt( "wgap" );
				
				to.setEmot(emot);
				to.setSeq(seq);
				to.setSubject(subject);
				to.setWriter(writer);
				to.setWdate(wdate);
				to.setHit(hit);
				to.setWgap(wgap);
				
				lists.add( to );
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return lists;
	}
	
	//paging list
	public BoardListTO boardList( BoardListTO listTO) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		// 페이지를 위한 기본 요소
		int cpage = listTO.getCpage();
		int recordPerPage = listTO.getRecordPerPage();
		int BlockPerPage = listTO.getBlockPerPage();
		
		try {
			conn = dataSource.getConnection();
			
			String sql = "select emot, seq, subject, writer, date_format(wdate, '%Y-%m-%d') wdate, hit, datediff(now(), wdate) wgap from board2 order by seq desc";
			pstmt = conn.prepareStatement( sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
			rs = pstmt.executeQuery();
			
			rs.last();
			listTO.setTotalRecord( rs.getRow() );
			rs.beforeFirst();
			
			listTO.setTotalPage( ( (listTO.getTotalRecord() - 1) / recordPerPage ) + 1 );
			int skip = (cpage -1) * recordPerPage;
			if (skip != 0) rs.absolute( skip );
			
			ArrayList<BoardTO> lists = new ArrayList<BoardTO>();
			
			for( int i=0; i<recordPerPage && rs.next(); i++) {
				BoardTO to = new BoardTO();
				String emot = rs.getString( "emot" );
				String seq = rs.getString( "seq" );
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				String wdate = rs.getString( "wdate" );
				String hit = rs.getString( "hit" );
				int wgap = rs.getInt( "wgap" );
				
				to.setEmot(emot);
				to.setSeq(seq);
				to.setSubject(subject);
				to.setWriter(writer);
				to.setWdate(wdate);
				to.setHit(hit);
				to.setWgap(wgap);
				
				lists.add( to );
			}
			listTO.setBoardLists( lists );
			
			listTO.setStartBlock( ( (cpage-1)/BlockPerPage ) * BlockPerPage + 1 );
			listTO.setEndBlock( ( (cpage-1)/BlockPerPage ) * BlockPerPage + BlockPerPage );
			if ( listTO.getEndBlock() >= listTO.getTotalPage() ) {
				listTO.setEndBlock( listTO.getTotalPage() );
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return listTO;
	}
	
	//view
	public BoardTO boardView( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			//조회수 증가시키기
			String sql = "update board2 set hit = hit+1 where seq = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 해당 글 내용 가져오기
			sql = "select subject, writer, mail, content, hit, wip, wdate, emot from board2 where seq = ?";
			pstmt = conn.prepareStatement( sql );
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 sql실행문의 각 컬럼을 가져와서 변수에 저장
			if ( rs.next() ) {
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				String mail = rs.getString( "mail" );
				String content = rs.getString( "content" );
				String hit = rs.getString( "hit" );
				String wip = rs.getString( "wip" );
				String wdate = rs.getString( "wdate" );
				String emot = rs.getString( "emot" );
				
				to.setSubject(subject);
				to.setWriter(writer);
				to.setMail(mail);
				to.setContent(content);
				to.setHit(hit);
				to.setWip(wip);
				to.setWdate(wdate);
				to.setEmot(emot);
			}
		
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//delete
	public BoardTO boardDelete( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에서 해당 글 내용 가져오기
			String sql = "select subject, writer from board2 where seq = ?";
			pstmt = conn.prepareStatement( sql );
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 sql실행문의 각 컬럼을 가져와서 변수에 저장
			if ( rs.next() ) {
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				
				to.setSubject(subject);
				to.setWriter(writer);
			}
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//delete_ok
	public int boardDeleteOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		int flag = 2;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에서 해당 글 내용 가져오기
			String sql = "delete from board2 where seq = ? and password = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSeq() );
			pstmt.setString( 2, to.getPassword() );
			
			int result = pstmt.executeUpdate();
			if ( result == 0 ) {
				flag = 1;
			} else if ( result ==1 ) {
				flag = 0;
			}
		
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return flag;
	}
	
	//modify
	public BoardTO boardModify( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에서 해당 글 내용 가져오기
			String sql = "select writer, subject, content, mail, emot from board2 where seq = ?";
			pstmt = conn.prepareStatement( sql );
			pstmt.setString( 1, to.getSeq() );
			rs = pstmt.executeQuery();
			
			//데이터베이스에서 sql실행문의 각 컬럼을 가져와서 변수에 저장
			if ( rs.next() ) {
				String subject = rs.getString( "subject" );
				String writer = rs.getString( "writer" );
				String content = rs.getString( "content" );
				String mail = rs.getString( "mail" );
				String emot = rs.getString( "emot" );
				
				to.setSubject(subject);
				to.setWriter(writer);
				to.setContent(content);
				to.setMail(mail);
				to.setEmot(emot);
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( rs != null ) try { rs.close(); } catch ( SQLException e ) {}
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return to;
	}
	
	//modify_ok
	public int boardModifyOk( BoardTO to ) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		int flag = 2;
		
		try {
			conn = dataSource.getConnection();
			
			//데이터베이스에서 해당 글 내용 가져오기
			String sql = "update board2 set subject = ?, content = ?, mail = ?, emot = ? where seq = ? and password = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, to.getSubject() );
			pstmt.setString( 2, to.getContent() );
			pstmt.setString( 3, to.getMail() );
			pstmt.setString( 4, to.getEmot() );
			pstmt.setString( 5, to.getSeq() );
			pstmt.setString( 6, to.getPassword() );
			
			int result = pstmt.executeUpdate();
			if ( result == 0 ) {
				flag = 1;
			} else if ( result ==1 ) {
				flag = 0;
			}
			
		} catch (SQLException e) {
			System.out.println( "error : " + e.getMessage() );
		} finally {
			if ( pstmt != null ) try { pstmt.close(); } catch ( SQLException e ) {}
			if ( conn != null ) try { conn.close(); } catch ( SQLException e ) {}
		}
		return flag;
	}
}

-board_list1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%@ page import="model1.BoardListTO" %>
<%@ page import="model1.BoardTO" %>
<%@ page import="model1.BoardDAO" %>
<%@ page import="java.util.ArrayList" %>

<%
	request.setCharacterEncoding( "utf-8" );

	int cpage = 1;
	if ( request.getParameter( "cpage" ) != null && !request.getParameter( "cpage" ).equals("") ) {
		cpage = Integer.parseInt( request.getParameter( "cpage" ) );
	}
	
	BoardListTO listTO = new BoardListTO();
	listTO.setCpage(cpage);
	
	BoardDAO dao = new BoardDAO();
	listTO = dao.boardList(listTO);
	
	int recordPerPage = listTO.getRecordPerPage();
	int totalRecord = listTO.getTotalRecord();
	int totalPage = listTO.getTotalPage();
	int blockPerPage = listTO.getBlockPerPage();
	int blockRecord = listTO.getBlockRecord();
	int startBlock = listTO.getStartBlock();
	int endBlock = listTO.getEndBlock();
	
	ArrayList<BoardTO> lists = listTO.getBoardLists();
	
	StringBuffer sbHtml = new StringBuffer();
	
	
	for ( BoardTO to : lists ) {
		blockRecord++;
		String emot = to.getEmot();
		String seq = to.getSeq();
		String subject = to.getSubject();
		String writer = to.getWriter();
		String wdate = to.getWdate();
		String hit = to.getHit();
		int wgap = to.getWgap();
		
		sbHtml.append(" <tr> ");
		sbHtml.append(" 	<td><img src='../../images/emoticon/" + emot + ".png' width='15'/></td> ");
		sbHtml.append(" 	<td>" + seq + "</td> ");
		sbHtml.append(" 	<td class='left'><a href='board_view1.jsp?cpage=" + cpage + "&seq=" + seq + "'>" + subject + "</a>&nbsp ");
		if ( wgap == 0 ) {
			sbHtml.append(" 		<img src='../../images/icon_hot.gif' alt='HOT'></td> ");	
		}
		sbHtml.append(" 	</td> ");
		sbHtml.append(" 	<td>" + writer + "</td> ");
		sbHtml.append(" 	<td>" + wdate + "</td> ");
		sbHtml.append(" 	<td>" + hit + "</td> ");
		sbHtml.append(" 	<td>&nbsp;</td> ");
		sbHtml.append(" </tr> ");
	}

%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_list.css">
</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<div class="contents_sub">
		<div class="board_top">
			<div class="bold">총 <span class="txt_orange"><%= blockRecord %></span>건</div>
		</div>

		<!--게시판-->
		<div class="board">
			<table>
			<tr>
				<th width="3%">&nbsp;</th>
				<th width="5%">번호</th>
				<th>제목</th>
				<th width="10%">글쓴이</th>
				<th width="17%">등록일</th>
				<th width="5%">조회</th>
				<th width="3%">&nbsp;</th>
			</tr>
			<%= sbHtml %>
			</table>
		</div>	
		<div class="align_right">
			<input type="button" value="쓰기" class="btn_write btn_txt01" style="cursor: pointer;" onclick="location.href='board_write1.jsp?cpage=<%=cpage %>'" />
		</div>
		<!--//게시판-->
	</div>
</div>
<!--//하단 디자인 -->
<!--페이지넘버-->
		<div class="paginate_regular">
			<div align="absmiddle">
<%
		
		if ( startBlock == 1 ) {
			out.println(" <span><a>&lt;&lt;</a></span> ");
		} else {
			out.println(" <span><a href='board_list1.jsp?cpage="+ (startBlock-blockPerPage) +"'>&lt;&lt;</a></span> ");
		}
		out.println(" &nbsp; ");
		
		if ( cpage == 1 ) {
			out.println(" <span><a>&lt;</a></span> ");
		} else {
			out.println(" <span><a href='board_list1.jsp?cpage="+ (cpage-1) +"'>&lt;</a></span> ");
		}
		out.println(" &nbsp;&nbsp; ");
		
		for ( int i=startBlock; i<=endBlock; i++ ) {
			if ( cpage == i ) { 
				out.println(" <span>[" + i + "]</span> ");
			} else {
				out.println(" <span><a href='board_list1.jsp?cpage=" + i + "'>" + i + "</a></span> ");
			}
		}
		out.println(" &nbsp;&nbsp; ");
		
		if ( cpage == totalPage ) {
			out.println(" <span><a>&gt;</a></span> ");
		} else {
			out.println(" <span><a href='board_list1.jsp?cpage="+ (cpage+1) +"'>&gt;</a></span> ");
		}
		out.println(" &nbsp; ");
		
		if ( endBlock == totalPage ) {
			out.println(" <span><a>&gt;</a></span> ");
		} else {
			out.println(" <span><a href='board_list1.jsp?cpage="+ (startBlock+blockPerPage) +"'>&gt;&gt;</a></span> ");
		}
		out.println(" &nbsp; ");
		
		
		
%>
			</div>
		</div>
		<!--//페이지넘버-->
</body>
</html>

 

 

부록B 파일 업로드

p697

1. form
	<form method="post" enctype="multipart/form-data"
	<input type="file"

2. cos.jar
	클래스명: MultipartRequest
		메서드명: multipart 파서

이들이 있어야 파일을 서버에 올릴 수 있다.

cos.jar 라이브러리는 아래에서 다운받는다.

cos.jar
0.05MB

 

 

 

ㅇ파일 업로드 하기

-upload_form.jsp (= 클라이언트쪽)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<!-- upload_ok01.jsp에 파일을 업로드 시킨다는 뜻 -->
<form action="upload_ok01.jsp" method="post" enctype="multipart/form-data">
파일 : <input type="file" name="upload" />
<input type="submit" value="파일 전송">
</form>

</body>
</html>

-upload_ok01.jsp (= 서버쪽)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>

<%
	// 절대경로를 사용해야한다.
	// C:/Java/jsp-workspace/UploadEx01/WebContent/upload
	// 제한용량 설정, 인코딩
	
	//1. 절대경로 설정
	String uploadPath = "C:/Java/jsp-workspace/UploadEx01/WebContent/upload";
	
	//2. 업로드 제한용량 설정(byte)
	int maxFileSize = 1024 * 1024 * 2; //2mb
	
	//3. 인코딩 타입 설정
	String encType = "utf-8";
	
	MultipartRequest multi 
		= new MultipartRequest( request, uploadPath, maxFileSize, encType, new DefaultFileRenamePolicy() );
	
	out.println( "업로드 완료" );
%>

2mb이내에 파일을 아무거나 업로드한다. cos.jar 파일을 업로드 시켜본다.

 

 

-업로드 정보 알아내기

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>

<%
	//1. 절대경로 설정
	String uploadPath = "C:/Java/jsp-workspace/UploadEx01/WebContent/upload";
	
	//2. 업로드 제한용량 설정(byte)
	int maxFileSize = 1024 * 1024 * 2; //2mb
	
	//3. 인코딩 타입 설정
	String encType = "utf-8";
	
	MultipartRequest multi 
		= new MultipartRequest( request, uploadPath, maxFileSize, encType, new DefaultFileRenamePolicy() );
	
	
	out.println( "업로드 완료<br>" );
	
	//DefaultFileRenamePolicy() 는 적용된 변경된 파일명 출력
	out.println( "파일이름: " + multi.getFilesystemName( "upload" ) + "<br>" );
	
	//원래의 파일명 출력
	out.println( "파일이름: " + multi.getOriginalFileName( "upload" ) + "<br>" );
	
	//파일 용량 알아내기
	java.io.File file = multi.getFile( "upload" );
	out.println( "파일용량: " + file.length() + "<br>" );
	
	//다운로드
	out.println( "<a href='./upload/"+ multi.getFilesystemName( "upload" ) +"'>다운로드</a>");
%>

다운로드하려면 실행하고 나서 이클립스의 upload폴더를 새로고침하고 다운로드 버튼을 누르면 다운로드가 시작된다.

 

 

 

ㅇ파일첨부할 수 있는 게시판 만들기

-필요파일(css and imge)

image_css.zip
0.21MB

 

 

 

-디렉터리 

첨부파일이 담겨질 폴더 upload 를 만든다.

-데이터베이스 테이블

create table pds_board1 (
seq int not null primary key auto_increment,
subject varchar(150) not null,
writer varchar(12) not null,
mail varchar(50),
password varchar(12)	 not null,
content varchar(2000),
filename varchar(50),
filesize int,
hit int not null,
wip varchar(15) not null,
wdate datetime not null
);

-board_list1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.sql.DataSource" %>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>



<%

	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	int totalRecord = 0;
	
	StringBuffer sbHtml = new StringBuffer();
	
	try {
		//커넥션 풀로 DB에 연결하기
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
		DataSource dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		conn = dataSource.getConnection();
		
		String sql = "select seq, subject, writer, filesize, date_format(wdate, '%Y-%m-%d') wdate, hit, datediff(now(), wdate) wgap from pds_board1 order by seq desc";
		pstmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
		rs = pstmt.executeQuery();
		
		//읽을 위치를 맨아래로
		rs.last();
		//전체 데이터 개수
		totalRecord = rs.getRow();
		rs.beforeFirst();
		
		while( rs.next() ) {
			String seq = rs.getString( "seq" );
			String subject = rs.getString( "subject" );
			String writer = rs.getString( "writer" );
			long filesize = rs.getLong( "filesize" );
			String wdate = rs.getString( "wdate" );
			String hit = rs.getString( "hit" );
			int wgap = rs.getInt( "wgap" );
			
			sbHtml.append( " <tr> " );
			sbHtml.append( " 	<td>&nbsp;</td> " );
			sbHtml.append( " 	<td>" + seq + "</td> " );
			sbHtml.append( "	<td class='left'> ");
			sbHtml.append( "		<a href='board_view1.jsp?seq=" + seq + "'>" + subject + "</a>&nbsp; ");
			if( wgap == 0 ) {
				sbHtml.append( "		<img src='../../images/icon_hot.gif' alt='HOT'> ");
			}
			sbHtml.append( "	</td> " );
			sbHtml.append( " 	<td>" + writer + "</td> " );
			sbHtml.append( " 	<td>" + wdate + "</td> " );
			sbHtml.append( " 	<td>" + hit + "</td> " );
			if ( filesize != 0 ) {
				sbHtml.append( " 	<td><img src='../../images/icon_file.gif' /></td> " );
			} else {
				sbHtml.append( " 	<td>&nbsp;</td> " );
			}
			sbHtml.append( " </tr> " );
		}

		
	} catch(NamingException e) {
		System.out.println( "error: " + e.getMessage() );
	} catch(SQLException e) {
		System.out.println( "error: " + e.getMessage() );
	} finally {
		if ( rs != null ) rs.close();
		if ( pstmt != null ) pstmt.close();
		if ( conn != null ) conn.close();
	}
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_list.css">
</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<div class="contents_sub">
		<div class="board_top">
			<div class="bold">총 <span class="txt_orange"><%= totalRecord %></span>건</div>
		</div>

		<!--게시판-->
		<div class="board">
			<table>
			<tr>
				<th width="3%">&nbsp;</th>
				<th width="5%">번호</th>
				<th>제목</th>
				<th width="10%">글쓴이</th>
				<th width="17%">등록일</th>
				<th width="5%">조회</th>
				<th width="3%">&nbsp;</th>
			</tr>
			<%= sbHtml %>
			</table>
		</div>	
		<!--//게시판-->

		<div class="align_right">
			<input type="button" value="쓰기" class="btn_write btn_txt01" style="cursor: pointer;" onclick="location.href='board_write1.jsp'" />
		</div>
	</div>
</div>
<!--//하단 디자인 -->

</body>
</html>

-board_write1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_write.css">

<script type="text/javascript">
	window.onload = function() {
		document.getElementById( 'submit1' ).onclick = function() {
			if ( document.wfrm.info.checked == false ) {
				alert( '동의를 해주세요' );
				return false;
			}
			if ( document.wfrm.writer.value.trim() == '' ) {
				alert( '글쓴이를 입력해주세요' );
				return false;
			}
			if ( document.wfrm.subject.value.trim() == '' ) {
				alert( '제목을 입력해주세요' );
				return false;
			}
			if ( document.wfrm.password.value.trim() == '' ) {
				alert( '비밀번호를 입력해주세요' );
				return false;
			}
			document.wfrm.submit();
		}
	}
</script>

</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<form action="board_write1_ok.jsp" method="post" name="wfrm" enctype="multipart/form-data">
		<div class="contents_sub">	
			<!--게시판-->
			<div class="board_write">
				<table>
				<tr>
					<th class="top">글쓴이</th>
					<td class="top" colspan="3"><input type="text" name="writer" value="" class="board_view_input_mail" maxlength="5" /></td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan="3"><input type="text" name="subject" value="" class="board_view_input" /></td>
				</tr>
				<tr>
					<th>비밀번호</th>
					<td colspan="3"><input type="password" name="password" value="" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>내용</th>
					<td colspan="3"><textarea name="content" class="board_editor_area"></textarea></td>
				</tr>
				<tr>
					<th>이메일</th>
					<td colspan="3"><input type="text" name="mail1" value="" class="board_view_input_mail"/> @ <input type="text" name="mail2" value="" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>첨부파일</th>
					<td colspan="3">
						<input type="file" name="upload" value="파일첨부" class="board_view_input" />
					</td>
				</tr>
				</table>
				
				<table>
				<tr>
					<br />
					<td style="text-align:left;border:1px solid #e0e0e0;background-color:f9f9f9;padding:5px">
						<div style="padding-top:7px;padding-bottom:5px;font-weight:bold;padding-left:7px;font-family: Gulim,Tahoma,verdana;">※ 개인정보 수집 및 이용에 관한 안내</div>
						<div style="padding-left:10px;">
							<div style="width:97%;height:95px;font-size:11px;letter-spacing: -0.1em;border:1px solid #c5c5c5;background-color:#fff;padding-left:14px;padding-top:7px;">
								1. 수집 개인정보 항목 : 회사명, 담당자명, 메일 주소, 전화번호, 홈페이지 주소, 팩스번호, 주소 <br />
								2. 개인정보의 수집 및 이용목적 : 제휴신청에 따른 본인확인 및 원활한 의사소통 경로 확보 <br />
								3. 개인정보의 이용기간 : 모든 검토가 완료된 후 3개월간 이용자의 조회를 위하여 보관하며, 이후 해당정보를 지체 없이 파기합니다. <br />
								4. 그 밖의 사항은 개인정보취급방침을 준수합니다.
							</div>
						</div>
						<div style="padding-top:7px;padding-left:5px;padding-bottom:7px;font-family: Gulim,Tahoma,verdana;">
							<input type="checkbox" name="info" value="1" class="input_radio"> 개인정보 수집 및 이용에 대해 동의합니다.
						</div>
					</td>
				</tr>
				</table>
			</div>
			
			<div class="btn_area">
				<div class="align_left">
					<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
				</div>
				<div class="align_right">
					<input type="button" id="submit1" value="쓰기" class="btn_write btn_txt01" style="cursor: pointer;" />
				</div>
			</div>
			<!--//게시판-->
		</div>
	</form>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-board_wirte1_ok.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.sql.DataSource" %>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.SQLException" %>

<%@ page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<%@ page import="java.io.File" %>

<%
	String uploadPath = "C:/Java/jsp-workspace/BoardEx01/WebContent/upload";
	int maxFileSize = 1024 * 1024 * 10;
	String encType = "utf-8";
	MultipartRequest multi 
		= new MultipartRequest( request, uploadPath, maxFileSize, encType, new DefaultFileRenamePolicy() );
	//request.setCharter는 request와 encType이 대신하기때문에 이제 request대신에 multi로 들어가서 데이터에 접근한다.

	String subject = multi.getParameter( "subject" );
	String writer = multi.getParameter( "writer" );
	//필수입력항목이 아닌경우 아래와 같이 값을 검사하고 저장해야 한다.
	String mail = "";
	if ( !multi.getParameter( "mail1" ).equals("") && !multi.getParameter( "mail2" ).equals("") ) {
		mail = multi.getParameter( "mail1" ) +  "@" + multi.getParameter( "mail2" );
	}
	String password = multi.getParameter( "password" );
	String content = multi.getParameter( "content" );
	String wip = request.getRemoteAddr();	//환경값만 request사용
	
	String filename = multi.getFilesystemName( "upload" );
	File file = multi.getFile( "upload" );
	long filesize = 0;
	if ( file != null ) {
		filesize = file.length();
	}

	Connection conn = null;
	PreparedStatement pstmt = null;
	
	//정상처리인지 비정상처리인지를 구분하는 변수 -> 결과를 한 군데에서 통합처리하기 위한 변수
	int flag = 1;
	
	try {
		//커넥션 풀로 DB에 연결하기
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
		DataSource dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		conn = dataSource.getConnection();
		
		String sql = "insert into pds_board1 values (0, ?, ?, ?, ?, ?, ?, ?, 0, ?, now() )";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString( 1, subject );
		pstmt.setString( 2, writer );
		pstmt.setString( 3, mail );
		pstmt.setString( 4, password );
		pstmt.setString( 5, content );
		pstmt.setString( 6, filename );
		pstmt.setLong( 7, filesize );
		pstmt.setString( 8, wip );
		
		int result = pstmt.executeUpdate();
		if ( result == 1 ) {
			//정상일 때
			flag = 0;
		}
	} catch(NamingException e) {
		System.out.println( "error: " + e.getMessage() );
	} catch(SQLException e) {
		System.out.println( "error: " + e.getMessage() );
	} finally {
		if ( pstmt != null ) pstmt.close();
		if ( conn != null ) conn.close();
	}
	
	out.println( " <script type='text/javascript'> " );
	if( flag == 0 ) {
		out.println( " alert('글쓰기에 성공했습니다.'); " );
		out.println( " location.href='board_list1.jsp;'" );
	} else {
		out.println( " alert('글쓰기에 실패했습니다.'); " );
		out.println( " history.back(); " );
	}
	out.println( " </script> " );
	

%>


-board_view1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.sql.DataSource" %>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>

<%
	request.setCharacterEncoding( "utf-8" );
	
	String seq = request.getParameter( "seq" );
	String subject = "";
	String writer = "";
	String mail = "";
	String wip = "";
	String wdate = "";
	String hit = "";
	String content = "";
	String filename = "";
	long filesize = 0;
	String file = "";
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	
	try {
		//커넥션 풀로 DB에 연결하기
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
		DataSource dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		conn = dataSource.getConnection();
		
		//board_view.jsp에 들어오면 조회수 증가를 위한 update문을 사용한다.
		String sql = "update pds_board1 set hit = hit+1 where seq = ?";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString( 1, seq );
		rs = pstmt.executeQuery();
		
		sql = "select subject, writer, filename, filesize, mail, wip, wdate, hit, content from pds_board1 where seq = ?";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString( 1, seq );
		rs = pstmt.executeQuery();
		
		//데이터를 하나만 가져오니깐 while문 대신 if문을 사용한다.
		if ( rs.next() ) {
			subject = rs.getString( "subject" );
			writer = rs.getString( "writer" );
			mail = rs.getString( "mail" );
			wip = rs.getString( "wip" );
			wdate = rs.getString( "wdate" );
			hit = rs.getString( "hit" );
			filename = rs.getString( "filename" );
			filesize = rs.getLong( "filesize" );
			if ( filesize != 0 ) {
				file = "<a href='../../upload/" + filename + "'>" + filename + "</a> (" + filesize + "byte)";
			}
			content = rs.getString( "content" ).replaceAll( "\n", "<br>");
		}

		
	} catch(NamingException e) {
		System.out.println( "error: " + e.getMessage() );
	} catch(SQLException e) {
		System.out.println( "error: " + e.getMessage() );
	} finally {
		if ( rs != null ) rs.close();
		if ( pstmt != null ) pstmt.close();
		if ( conn != null ) conn.close();
	}
	
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_view.css">
</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<div class="contents_sub">
		<!--게시판-->
		<div class="board_view">
			<table>
			<tr>
				<th width="10%">제목</th>
				<td width="60%"><%= subject %></td>
				<th width="10%">등록일</th>
				<td width="20%"><%= wdate %></td>
			</tr>
			<tr>
				<th>글쓴이</th>
				<td><%= writer %>(<%= mail %>)(<%= wip %>)</td>
				<th>조회</th>
				<td><%= hit %></td>
			</tr>
			<tr>
				<th>첨부 파일</th>
				<td><%= file %></td>

			</tr>
			<tr>
				<td colspan="4" height="200" valign="top" style="padding: 20px; line-height: 160%"><%= content %></td>
			</tr>
			</table>
		</div>

		<div class="btn_area">
			<div class="align_left">
				<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
			</div>
			<div class="align_right">
				<input type="button" value="수정" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_modify1.jsp?seq=<%= seq %>'" />
				<input type="button" value="삭제" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_delete1.jsp?seq=<%= seq %>'" />
				<input type="button" value="쓰기" class="btn_write btn_txt01" style="cursor: pointer;" onclick="location.href='board_write1.jsp'" />
			</div>
		</div>	
		<!--//게시판-->
	</div>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-board_modify1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.sql.DataSource" %>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>

<%
	request.setCharacterEncoding( "utf-8" );
	
	String seq = request.getParameter( "seq" );
	
	String writer = "";
	String subject = "";
	String content = "";
	//String mail1 = "";
	//String mail2 = "";
	String mail[] = null;
	String emot = "";
	String filename = "";
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	
	try {
		//커넥션 풀로 DB에 연결하기
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
		DataSource dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		conn = dataSource.getConnection();
		
		String sql = "select writer, subject, content, mail, filename from pds_board1 where seq = ?";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString( 1, seq );
		rs = pstmt.executeQuery();
		
		//데이터를 하나만 가져오니깐 while문 대신 if문을 사용한다.
		if ( rs.next() ) {
			subject = rs.getString( "subject" );
			writer = rs.getString( "writer" );
			content = rs.getString( "content" );
			if ( rs.getString( "filename" ) != null ) {
				filename = rs.getString( "filename" );
			}
			if ( rs.getString("mail").equals("") ) {
				mail = new String[] {"", ""};
			} else {
				mail = rs.getString( "mail" ).split("@");
			}
			//mail1 = rs.getString( "mail1" );
			//mail2 = rs.getString( "mail2" );
		}

		
	} catch(NamingException e) {
		System.out.println( "error: " + e.getMessage() );
	} catch(SQLException e) {
		System.out.println( "error: " + e.getMessage() );
	} finally {
		if ( rs != null ) rs.close();
		if ( pstmt != null ) pstmt.close();
		if ( conn != null ) conn.close();
	}
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_write.css">

<script type="text/javascript">
 	window.onload = function() {
 		document.getElementById( 'submit2' ).onclick = function() {
 			if ( document.mfrm.subject.value.trim() == '' ) {
 				alert( '제목을 입력해주세요' );
 				return false;
 			}
 			if ( document.mfrm.password.value.trim() == '' ) {
 				alert( '비밀번호를 입력해주세요' );
 				return false;
 			}
 			if ( document.mfrm.content.value.trim() == '' ) {
 				alert( '내용을 입력해주세요' );
 				return false;
 			}
 			document.mfrm.submit();
 		}
 	}
</script>

</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<form action="board_modify1_ok.jsp" method="post" name="mfrm" enctype="multipart/form-data">
		<input type="hidden" name="seq" value="<%= seq %>">
		<div class="contents_sub">	
			<!--게시판-->
			<div class="board_write">
				<table>
				<tr>
					<th class="top">글쓴이</th>
					<td class="top" colspan="3"><input type="text" name="writer" value="<%= writer %>" class="board_view_input_mail" maxlength="5" readonly/></td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan="3"><input type="text" name="subject" value="<%= subject %>" class="board_view_input" /></td>
				</tr>
				<tr>
					<th>비밀번호</th>
					<td colspan="3"><input type="password" name="password" value="" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>내용</th>
					<td colspan="3"><textarea name="content" class="board_editor_area"><%= content %></textarea></td>
				</tr>
				<tr>
					<th>이메일</th>
					<td colspan="3"><input type="text" name="mail1" value="<%= mail[0] %>" class="board_view_input_mail"/> @ <input type="text" name="mail2" value="<%= mail[1] %>" class="board_view_input_mail"/></td>
				</tr>
				<tr>
					<th>첨부파일</th>
					<td colspan="3">
						기존 파일명 : <%=filename %><br /><br />
						<input type="file" name="upload" value="" class="board_view_input" />
					</td>
				</tr>
				</table>
			</div>
			
			<div class="btn_area">
				<div class="align_left">
					<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
					<input type="button" value="보기" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_view1.jsp?seq=<%=seq %>'" />
				</div>
				<div class="align_right">
					<input type="button" id="submit2" value="수정" class="btn_write btn_txt01" style="cursor: pointer;" />
				</div>
			</div>
			<!--//게시판-->
		</div>
	</form>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-board_modify1_ok.jsp

<%@page import="java.sql.ResultSet"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.sql.DataSource" %>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.SQLException" %>

<%@ page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<%@ page import="java.io.File" %>

<%
	String uploadPath = "C:/Java/jsp-workspace/BoardEx01/WebContent/upload";
	int maxFileSize = 1024 * 1024 * 10;
	String encType = "utf-8";
	MultipartRequest multi 
		= new MultipartRequest( request, uploadPath, maxFileSize, encType, new DefaultFileRenamePolicy() );

	String seq = multi.getParameter( "seq" );
	String password = multi.getParameter( "password" );
	String subject = multi.getParameter( "subject" );
	String content = multi.getParameter( "content" );
	String mail = "";
	if ( !multi.getParameter( "mail1" ).equals("") && !multi.getParameter( "mail2" ).equals("") ) {
		mail = multi.getParameter( "mail1" ) + "@" + multi.getParameter( "mail2" );
	}
	String newFilename = multi.getFilesystemName( "upload" );
	File newFile = multi.getFile( "upload" );
	long newFilesize = 0;
	if ( newFile != null ) {
		newFilesize = newFile.length();
	}
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	
	//정상처리인지 비정상처리인지를 구분하는 변수 -> 결과를 한 군데에서 통합처리하기 위한 변수
	int flag = 2;
	
	try {
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
		DataSource dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		conn = dataSource.getConnection();
		
		String sql = "select filename from pds_board1 where seq = ?";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString(1, seq);
		rs = pstmt.executeQuery();
		String oldFilename = null;
		if ( rs.next() ) {
			oldFilename = rs.getString( "filename" );
		}
		
		if ( newFilename != null ) {
			//수정에서 첨부파일이 있을 때
			sql = "update pds_board1 set subject = ?, content = ?, mail = ?, filename = ?, filesize = ? where seq = ? and password = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, subject );
			pstmt.setString( 2, content );
			pstmt.setString( 3, mail );
			pstmt.setString( 4, newFilename );
			pstmt.setLong( 5, newFilesize );
			pstmt.setString( 6, seq );
			pstmt.setString( 7, password );
		} else {
			//수정에서 첨부파일이 없을 때
			sql = "update pds_board1 set subject = ?, content = ?, mail = ? where seq = ? and password = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString( 1, subject );
			pstmt.setString( 2, content );
			pstmt.setString( 3, mail );
			pstmt.setString( 4, seq );
			pstmt.setString( 5, password );
		}
		int result = pstmt.executeUpdate();
		
		
		if ( result == 0 ) {
			flag = 1;
		} else if ( result == 1 ) {
			flag = 0;
			if ( newFilename != null && oldFilename != null ) {
				//기존 첨부파일이 있고 추가된 첨부파일이 있을 경우 기존 파일은 삭제한다.
				File file = new File( "C:/Java/jsp-workspace/BoardEx01/WebContent/upload/"+ oldFilename );
				file.delete();
			}
		}
		
	} catch(NamingException e) {
		System.out.println( "error: " + e.getMessage() );
	} catch(SQLException e) {
		System.out.println( "error: " + e.getMessage() );
	} finally {
		if ( pstmt != null ) pstmt.close();
		if ( conn != null ) conn.close();
	}
	
	out.println( " <script type='text/javascript'> " );
	if( flag == 0 ) {
		out.println( " alert('글수정에 성공했습니다.'); " );
		out.println( " location.href='board_modify1.jsp?seq=" + seq + "'" );
	} else if ( flag == 1 ) {
		out.println( " alert('비밀번호가 틀립니다.'); " );
		out.println( " history.back(); " );
	} else {
		out.println( " alert('글수정에 실패했습니다.'); " );
		out.println( " history.back(); " );
	}
	out.println( " </script> " );
	
%>

-board_delete1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.sql.DataSource" %>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>

<%
	request.setCharacterEncoding( "utf-8" );
	
	String seq = request.getParameter( "seq" );
	
	String subject = "";
	String writer = "";
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	
	try {
		//커넥션 풀로 DB에 연결하기
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
		DataSource dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		conn = dataSource.getConnection();
		
		String sql = "select subject, writer from pds_board1 where seq = ?";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString( 1, seq );
		rs = pstmt.executeQuery();
		
		//데이터를 하나만 가져오니깐 while문 대신 if문을 사용한다.
		if ( rs.next() ) {
			subject = rs.getString( "subject" );
			writer = rs.getString( "writer" );
		}

		
	} catch(NamingException e) {
		System.out.println( "error: " + e.getMessage() );
	} catch(SQLException e) {
		System.out.println( "error: " + e.getMessage() );
	} finally {
		if ( rs != null ) rs.close();
		if ( pstmt != null ) pstmt.close();
		if ( conn != null ) conn.close();
	}
%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/board_write.css">

<script type="text/javascript">
	window.onload = function() {
		document.getElementById( 'submit1' ).onclick = function() {
			if( document.dfrm.password.value.trim() == '' ) {
				alert( '비밀번호를 입력해주세요' );
				return false;
			}
			document.dfrm.submit();
		}
	}
</script>

</head>

<body>
<!-- 상단 디자인 -->
<div class="con_title">
	<h3>게시판</h3>
	<p>HOME &gt; 게시판 &gt; <strong>게시판</strong></p>
</div>
<div class="con_txt">
	<form action="board_delete1_ok.jsp" method="post" name="dfrm">
		<input type="hidden" name="seq" value="<%= seq %>">
		<div class="contents_sub">	
			<!--게시판-->
			<div class="board_write">
				<table>
				<tr>
					<th class="top">글쓴이</th>
					<td class="top" colspan="3"><input type="text" name="writer" value="<%= writer %>" class="board_view_input_mail" maxlength="5" readonly/></td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan="3"><input type="text" name="subject" value="<%= subject %>" class="board_view_input" readonly/></td>
				</tr>
				<tr>
					<th>비밀번호</th>
					<td colspan="3"><input type="password" name="password" value="" class="board_view_input_mail"/></td>
				</tr>
				</table>
			</div>
			
			<div class="btn_area">
				<div class="align_left">
					<input type="button" value="목록" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_list1.jsp'" />
					<input type="button" value="보기" class="btn_list btn_txt02" style="cursor: pointer;" onclick="location.href='board_view1.jsp?seq=<%=seq %>'" />
				</div>
				<div class="align_right">
					<input type="button" id="submit1" value="삭제" class="btn_write btn_txt01" style="cursor: pointer;" />
				</div>
			</div>
			<!--//게시판-->
		</div>
	</form>
</div>
<!-- 하단 디자인 -->

</body>
</html>

-board_delete1_ok.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.sql.DataSource" %>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@page import="java.sql.ResultSet"%>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.io.File" %>

<%
	request.setCharacterEncoding( "utf-8" );

	String seq = request.getParameter( "seq" );
	String password = request.getParameter( "password" );
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	
	//정상처리인지 비정상처리인지를 구분하는 변수 -> 결과를 한 군데에서 통합처리하기 위한 변수
	int flag = 2;
	
	try {
		//커넥션 풀로 DB에 연결하기
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup( "java:comp/env" );
		DataSource dataSource = (DataSource)envCtx.lookup( "jdbc/mariadb2" );
		conn = dataSource.getConnection();
		
		//filename 가져와서 디렉터리에서 해당 파일 지우기
		//flag가 정상일때만 지워준다.
		String sql = "select filename from pds_board1 where seq = ?";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString(1, seq);
		
		rs = pstmt.executeQuery();
		String filename = null;
		if ( rs.next() ) {
			filename = rs.getString( "filename" );
		}
		
		sql = "delete from pds_board1 where seq = ? and password = ?";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString( 1, seq );
		pstmt.setString( 2, password );
		
		int result = pstmt.executeUpdate();
		
		if ( result == 0 ) {
			flag = 1;
		} else if ( result == 1 ) {
			flag = 0;
			if ( filename != null ) {
				File file = new File( "C:/Java/jsp-workspace/BoardEx01/WebContent/upload/"+ filename );
				file.delete();
			}
		}
	} catch(NamingException e) {
		System.out.println( "error: " + e.getMessage() );
	} catch(SQLException e) {
		System.out.println( "error: " + e.getMessage() );
	} finally {
		if ( pstmt != null ) pstmt.close();
		if ( conn != null ) conn.close();
	}
	
	out.println( " <script type='text/javascript'> " );
	if( flag == 0 ) {
		out.println( " alert('글삭제에 성공했습니다.'); " );
		out.println( " location.href='board_list1.jsp;' " );
	} else if ( flag == 1 ) {
		out.println( " alert('비밀번호가 틀립니다.'); " );
		out.println( " history.back(); " );
	} else {
		out.println( " alert('글삭제에 실패했습니다.'); " );
		out.println( " history.back(); " );
	}
	out.println( " </script> " );
	
%>

 

 

 

 

 

 

 

 

 

728x90
반응형
Comments