๐Ÿ’ป

JSP ํ”„๋กœ๊ทธ๋ž˜๋ฐ - [MVC/DB์—ฐ๋™] ํŒŒ์ผ์—…๋กœ๋“œ ๊ธฐ๋Šฅ ๋ณธ๋ฌธ

KITRI/JSP

JSP ํ”„๋กœ๊ทธ๋ž˜๋ฐ - [MVC/DB์—ฐ๋™] ํŒŒ์ผ์—…๋กœ๋“œ ๊ธฐ๋Šฅ

๋˜ํšจ๋‹ˆ 2020. 7. 9. 15:41

boardํด๋”(๊ฒŒ์‹œํŒ๋งŒ๋“ค๊ธฐ ํด๋”)๋ฅผ ๋ณต์‚ฌํ•ด์„œ fileboardํด๋”๋ฅผ ๋งŒ๋“ค์–ด๋ณด์ž.

ํŒŒ์ผ์ž…์ถœ๋ ฅ์„ ์œ„ํ•œ ๊ฒƒ์ด๊ณ  ๋‚˜๋จธ์ง€๋Š” ๋‹ค ๊ฐ™๋‹ค. (๋ณต์‚ฌํ•ด์„œ ํด๋”๋ฅผ ๋งŒ๋“ค ๋•Œ, ์ฃผ์†Œ๋ฅผ ์ž˜ ์‚ดํŽด์•ผํ•œ๋‹ค. ๊ผฌ์ด์ง€ ์•Š๋„๋ก ์ฃผ์˜!)

 

Orcle SQL developer 

์ˆ˜์ • ํ›„์— BoardDao.java๋กœ ๊ฐ€์„œ insert๋ฌธ์„ ๋ณ€๊ฒฝ์‹œ์ผœ์ฃผ์—ˆ๋‹ค. (์ƒˆ๋กœ์šด ์นผ๋Ÿผ์„ ์ถ”๊ฐ€ํ–ˆ๋”๋‹ˆ column๊ฐœ์ˆ˜๊ฐ€ ๋งž์ง€ ์•Š์•„์„œ insert๊ฐ€ ๋˜์งˆ ์•Š์•„ ๊ธ€์“ฐ๊ธฐ๊ฐ€ ๋˜์ง€ ์•Š์•˜๋‹ค)

 

(์ˆ˜์ •์ด ์ž˜ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•์€, ํ†ฐ์บฃ์„œ๋ฒ„๋กœ ์‹คํ–‰ํ•œ ๋‹ค์Œ ๊ฒฝ๋กœ๊ฐ€ /fileboard/ ๋กœ ์ž˜ ์ฐํžˆ๋Š” ์ง€ ํ™•์ธํ•œ๋‹ค.)

 

๋‹ค์šด๋กœ๋“œ ๋ฐ›์•„์„œ WEB-INF/libs ํด๋”์— .jarํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.

 

http://commons.apache.org/proper/commons-fileupload/

 

FileUpload – Home

Commons FileUpload The Commons FileUpload package makes it easy to add robust, high-performance, file upload capability to your servlets and web applications. FileUpload parses HTTP requests which conform to RFC 1867, "Form-based File Upload in HTML". That

commons.apache.org

https://commons.apache.org/proper/commons-io/download_io.cgi

 

Commons IO – Download Apache Commons IO

Download Apache Commons IO Using a Mirror We recommend you use a mirror to download our release builds, but you must verify the integrity of the downloaded files using signatures downloaded from our main distribution directories. Recent releases (48 hours)

commons.apache.org

 

 

Commons IO – Download Apache Commons IO

Download Apache Commons IO Using a Mirror We recommend you use a mirror to download our release builds, but you must verify the integrity of the downloaded files using signatures downloaded from our main distribution directories. Recent releases (48 hours)

commons.apache.org

 

 


ํŒŒ์ผ์—…๋กœ๋“œ ๊ธ€์“ฐ๊ธฐ

 

 

write.jsp

ํŒŒ์ผ ์ถ”๊ฐ€ ๋ถ€๋ถ„

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<c:set var="root" value="${pageContext.request.contextPath }" />
<html>
<head>
<meta charset="UTF-8">
<title>ํŒŒ์ผ๋ณด๋“œ ๊ธ€์ž‘์„ฑ ํŽ˜์ด์ง€</title>
<link rel="stylesheet" href="${root}/css/board/boardStyle.css" />
<script type="text/javascript" >
	function boardCheck(obj){
		//alert("OK");	
	}
	function replyFunc(root, boardNumber, groupNumber, sequenceNumber, sequenceLevel){
		var url = root + "/fileboard/write.do?boardNumber=" + boardNumber +
				"&groupNumber=" + groupNumber + "&sequenceNumber=" + sequenceNumber +
				"&sequenceLevel=" + sequenceLevel;
		
		location.href = url;
	}
	function delFunc(root, boardNumber, pageNumber){
		var url = root+ "/fileboard/delete.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
		
		location.href = url;
	
		/*var value = confirm("์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?");
		
		if(value == true){
			var url = root+ "/board/deleteOk.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
			alert(url);
		}else{
			alert("์ทจ์†Œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
		}*/
	}
	function updFunc(root, boardNumber, pageNumber){
		var url = root + "/fileboard/update.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;		
		location.href = url;
	}
</script>
</head>
<body>
	<form id="createform" action="${root}/fileboard/writeOk.do" method="post"
		onsubmit="return boardCheck(this)" enctype="multipart/form-data">
		<div id="title"><a href="${root}/fileboard/list.do">๊ธ€๋ชฉ๋ก</a></div>
			
		<div class="menu" style="border-bottom-width: 0px;">
			<input type="hidden" name="boardNumber" value="${boardNumber}" /> 
			<input type="hidden" name="groupNumber" value="${groupNumber}" /> 
			<input type="hidden" name="sequenceNumber" value="${sequenceNumber}" /> 
			<input type="hidden" name="sequenceLevel" value="${sequenceLevel}" />
			
			<div id="id">์ž‘์„ฑ์ž</div>
			<span> 
				<input type="text" name="writer" size="12" />
			</span>
		</div>

		<div class="menu" style="border-bottom-width: 0px;">
			<div id="id">์ œ๋ชฉ</div>
			<span> 
				<input type="text" name="subject" size="50" />
			</span>
		</div>

		<div class="menu" style="border-bottom-width: 0px;">
			<div id="id">์ด๋ฉ”์ผ</div>
			<span> 
				<input type="email" name="email" size="50" />
			</span>
		</div>

		<div class="content" style="border-bottom-width: 0px;">
			<div id="text">๋‚ด์šฉ</div>
			<span> 
				<textarea name="content" rows="12" cols="65"></textarea>
			</span>
		</div>

		<div class="menu" style="border-bottom-width: 0px;">
			<div id="id">๋น„๋ฐ€๋ฒˆํ˜ธ</div>
			<span> 
				<input type="password" name="password" size="30" />
			</span>
		</div>

		<!-- ํŒŒ์ผ ์—…๋กœ๋“œ -->
		<div class="menu" style="border-bottom-width: 0px;">
			<div id="id">ํŒŒ์ผ๋ช…</div>
			<span> 
				<input type="file" name="file" size="50" />
			</span>
		</div>
		
		<div class="menu" style="border-bottom-width: 3px; text-align: center;">
			<span> 
				<input type="submit" value="๊ธ€์“ฐ๊ธฐ" /> 
				<input type="reset" value="๋‹ค์‹œ์ž‘์„ฑ" /> 
				<input type="button" value="๋ชฉ๋ก๋ณด๊ธฐ" onclick="location.href='${root}/fileboard/list.do'"/>
			</span>
		</div>
	</form>
</body>
</html>

 

 

 

WriteCommand.java

package com.java.fileboard.command;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.java.command.Command;

public class WriteCommand implements Command {

    @Override
    public String proRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
	
	//๋ถ€๋ชจ๊ธ€(ROOT)
	int boardNumber = 0;	//ROOT๊ธ€์ด๋ฉด 0
	int groupNumber = 1;	//๊ทธ๋ฃน๋ฒˆํ˜ธ
	int sequenceNumber = 0;	//๊ธ€์ˆœ์„œ
	int sequenceLevel = 0;	//๊ธ€๋ ˆ๋ฒจ
	
	//๋‹ต๊ธ€์ธ๊ฒฝ์šฐ ๋ถ€๋ชจ๊ธ€์˜  DB ๊ธ€๋ฒˆํ˜ธ, ๊ทธ๋ฃน๋ฒˆํ˜ธ, ๊ธ€์ˆœ์„œ, ๊ธ€๋ ˆ๋ฒจ
	if(request.getParameter("boardNumber")!=null) {  
	    boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
	    groupNumber = Integer.parseInt(request.getParameter("groupNumber"));
	    sequenceNumber = Integer.parseInt(request.getParameter("sequenceNumber"));
	    sequenceLevel = Integer.parseInt(request.getParameter("sequenceLevel"));
	}
	
	logger.info(logMsg +"boardNumber:" + boardNumber); 
	logger.info(logMsg +"groupNumber:" + groupNumber); 
	logger.info(logMsg +"sequenceNumber:" + sequenceNumber); 
	logger.info(logMsg +"sequenceLevel:" + sequenceLevel); 
	
	request.setAttribute("boardNumber", boardNumber);
	request.setAttribute("groupNumber", groupNumber);
	request.setAttribute("sequenceNumber", sequenceNumber);
	request.setAttribute("sequenceLevel", sequenceLevel);
	
	return "/WEB-INF/views/fileboard/write.jsp";
    }
}

 

WriteOkCommand.java

package com.java.fileboard.command;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import com.java.command.Command;
import com.java.fileboard.model.BoardDao;
import com.java.fileboard.model.BoardDto;

public class WriteOkCommand implements Command {

   @Override
   public String proRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      
      DiskFileItemFactory factory = new DiskFileItemFactory();   //ํŒŒ์ผ ๋ณด๊ด€ ๊ฐ์ฒด
      ServletFileUpload upload = new ServletFileUpload(factory);   //์š”์ฒญ ์ฒ˜๋ฆฌ ๊ฐ์ฒด
      
      List<FileItem> list = upload.parseRequest(request);
      Iterator<FileItem> iter = list.iterator();

      BoardDto boardDto = new BoardDto();
      HashMap<String, String> dataMap = new HashMap<String, String>();
      
      while(iter.hasNext()) { //11๊ฐœ
         FileItem fileItem = iter.next();
         
         if(fileItem.isFormField()) {
             String name=fileItem.getFieldName();
             String value=fileItem.getString("utf-8");
             logger.info(logMsg + name + "\t" + value);
             
             dataMap.put(name, value);
	     /*
	      * String name=(fileItem.getFieldName()); 
	      * logger.info(logMsg + "text: " + name);
	      */
             
         }else {
             if(fileItem.getFieldName().equals("file")) {
        	 // ํŒŒ์ผ๋ช… fileItem.getName() / ํŒŒ์ผ์‚ฌ์ด์ฆˆ fileItem.getSize(), getInputStream()
        	 if(fileItem.getName()==null||fileItem.getName().equals("")) continue;
        	 
        	 upload.setFileSizeMax(1024*1024*10);	// byte * kb * mb * gb
        	 String fileName = System.currentTimeMillis() + "_"+fileItem.getName();
        	 
        	 //์ ˆ๋Œ€ ๊ฒฝ๋กœ
        	 String dir = "C:\\sohyunkim\\mvc\\workspace\\MVCHomePage\\WebContent\\pds";
        	 File file = new File(dir, fileName);
        	 
        	 //ํ†ฐ์บฃ ์‹ค์ œ ์„œ๋ฒ„ ๊ฒฝ๋กœ
        	 //String dir = request.getServletContext().getRealPath("\\pds\\");
        	 //logger.info(logMsg + dir);
        	 
		
        	 //File dir = new File("C:\\pds\\"); dir.mkdir();
		  
		 //File file = null; 
        	 //if(dir.exists() && dir.isDirectory()) { 
        	 //	file = new File(dir, fileItem.getName()); 
        	 //}
		 
        	 
            	 BufferedInputStream bis = null;
            	 BufferedOutputStream bos = null;
        	
        	 try {
        	     bis = new BufferedInputStream(fileItem.getInputStream(), 1024);
        	     bos = new BufferedOutputStream( new FileOutputStream(file), 1024);
        	     
        	     while(true) {
        		 int data = bis.read();
                	 if(data==-1) break;
                	 
                	 bos.write(data);
            	     }
		    
		} catch (Exception e) {
		    e.printStackTrace();
		} finally {
		    if(bis!=null) bis.close();
		    if(bos!=null) bos.close();
		}
        	 boardDto.setFileName(fileName);
        	 boardDto.setFileSize(fileItem.getSize());
        	 boardDto.setPath(file.getAbsolutePath());
 
             }
         }
      }
      
      boardDto.setDataMap(dataMap);
      boardDto.setWriteDate(new Date());
      logger.info(logMsg + boardDto.toString()); 
      
      int check = BoardDao.getInstance().insert(boardDto);
      logger.info(logMsg + check);
       
      request.setAttribute("check", check);
      
      return "/WEB-INF/views/fileboard/writeOk.jsp";
   }
}

 

 


ํŒŒ์ผ์—…๋กœ๋“œ ๊ธ€ ์ฝ๊ธฐ

 

read.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<c:set var="root" value="${pageContext.request.contextPath}" />
<html>
<head>
<meta charset="UTF-8">
<title>ํŒŒ์ผ๋ณด๋“œ ์ฝ๊ธฐ ํŽ˜์ด์ง€</title>
<link rel="stylesheet" href="${root}/css/board/boardStyle.css" />
<script type="text/javascript">
	function boardCheck(obj){
		//alert("OK");	
	}
	function replyFunc(root, boardNumber, groupNumber, sequenceNumber, sequenceLevel){
		var url = root + "/fileboard/write.do?boardNumber=" + boardNumber +
				"&groupNumber=" + groupNumber + "&sequenceNumber=" + sequenceNumber +
				"&sequenceLevel=" + sequenceLevel;
		
		location.href = url;
	}
	function delFunc(root, boardNumber, pageNumber){
		var url = root+ "/fileboard/delete.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
		
		location.href = url;

		/*var value = confirm("์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?");
		
		if(value == true){
			var url = root+ "/board/deleteOk.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
			alert(url);
		}else{
			alert("์ทจ์†Œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
		}*/
	}
	function updFunc(root, boardNumber, pageNumber){
		var url = root + "/fileboard/update.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;		
		location.href = url;
	}
</script>
</head>
<body>
	<div id="createform">
		<div class="menu" style="border-bottom-width: 0px;"> 
			<div id="id">๊ธ€๋ฒˆํ˜ธ</div>
			${boardDto.boardNumber}
		</div>
		
		<div class="menu" style="border-bottom-width: 0px;">
			<div id="id">์ž‘์„ฑ์ž</div>
			${boardDto.writer}
		</div>
		
		<div class="menu" style="border-bottom-width: 0px;">
			<div id="id">์กฐํšŒ์ˆ˜</div>
			${boardDto.readCount}
		</div>
		
		<div class="menu" style="border-bottom-width: 0px;">
			<div id="id">์ž‘์„ฑ์ผ</div>
			<fmt:formatDate value="${boardDto.writeDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
		</div>

		<div class="menu" style="border-bottom-width: 0px;">
			<div id="id">์ œ๋ชฉ</div>
			${boardDto.subject}
		</div>

		<div class="content" style="border-bottom-width: 0px;">
			<div id="text">๋‚ด์šฉ</div>
			${boardDto.content}
		</div>
		
		<c:if test="${boardDto.fileSize!=0}">
			<div class="menu" style="border-bottom-width: 0px;">
				<div id="id">ํŒŒ์ผ๋ช…</div>
				<a href="${root}/fileboard/download.do?boardNumber=${boardDto.boardNumber}">${boardDto.fileName}</a>
			</div>
		</c:if>

		<div class="menu" style="border-bottom-width: 3px; text-align: center;">
			<input type="button" value="๊ธ€์ˆ˜์ •" onclick="updFunc('${root}','${boardDto.boardNumber}','${pageNumber}')"/>	
			<input type="button" value="๊ธ€์‚ญ์ œ" onclick="delFunc('${root}','${boardDto.boardNumber}','${pageNumber}')"/>	
			<input type="button" value="๋‹ต๊ธ€" onclick="replyFunc('${root}','${boardDto.boardNumber}','${boardDto.groupNumber}','${boardDto.sequenceNumber}','${boardDto.sequenceLevel}')"/>	
			<input type="button" value="๊ธ€๋ชฉ๋ก" onclick="location.href='${root}/fileboard/list.do?pageNumber=${pageNumber}'"/>	
		</div>
	</div>
</body>
</html>

 

ReadCommand.java

package com.java.fileboard.command;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.java.fileboard.model.BoardDao;
import com.java.fileboard.model.BoardDto;
import com.java.command.Command;

public class ReadCommand implements Command {

    @Override
    public String proRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
	int boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
	int pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
	logger.info(logMsg + boardNumber + "," + pageNumber);
	
	BoardDto boardDto = BoardDao.getInstance().read(boardNumber);
	logger.info(logMsg + boardDto);
	
	if(boardDto.getFileSize()!=0) {
	    int index = boardDto.getFileName().indexOf("_")+1;
	    boardDto.setFileName(boardDto.getFileName().substring(index));
	}
	
	request.setAttribute("pageNumber", pageNumber);
	request.setAttribute("boardDto", boardDto);

	return "/WEB-INF/views/fileboard/read.jsp";
    }
}

 


ํŒŒ์ผ์—…๋กœ๋“œ ๊ธ€ ์ˆ˜์ •

 

update.jsp

 

UpdateCommand.java

 

updateOk.jsp

 

UpdateOkCommand.java

 

 

[์ˆ˜์ •]

๊ธฐ์กด ๊บผ ์ง€์šฐ๊ณ  ์ƒˆ๋กœ ์˜ฌ๋ฆฐ๋‹ค.

ํŒŒ์ผ ์ด๋ฆ„์ด ์—†์–ด๋„ ์—…๋กœ๋“œ ๋ฒ„ํŠผ์ด ์žˆ์–ด์•ผํ•จ.

์ด๋ฆ„ ์—†์–ด๋„ ๋นˆํ™”๋ฉด์œผ๋กœ 


ํŒŒ์ผ์—…๋กœ๋“œ ๊ธ€ ์‚ญ์ œ

 

delete.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<c:set var = "root" value = "${pageContext.request.contextPath}"/>
<html>
<head>
<meta charset="UTF-8">
<title>ํŒŒ์ผ๋ณด๋“œ ์‚ญ์ œ ํŽ˜์ด์ง€</title>
</head>
<body>
	<div align="center">
		<form action="${root}/fileboard/deleteOk.do" method="post">
			<input type="hidden" name="boardNumber" value="${boardNumber}"/>
			<input type="hidden" name="pageNumber" value="${pageNumber}"/>
			
			<div>๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.</div>
			<div>
				<input type="password" name="password"/>
			</div>
			<div>
				<input type="submit" value="๊ธ€์‚ญ์ œ"/>
				<input type="button" value="๋ชฉ๋ก๋ณด๊ธฐ" onclick="location.href='${root}/fileboard/list.do?pageNumber=${pageNumber}'"/>
			</div>
		</form>
	</div>
</body>
</html>

 

DeleteCommand.java

package com.java.fileboard.command;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.java.command.Command;

public class DeleteCommand implements Command {

    @Override
    public String proRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
	
	int boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
	int pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
	logger.info(logMsg + boardNumber + "\t" + pageNumber);
	
	request.setAttribute("boardNumber", boardNumber);
	request.setAttribute("pageNumber", pageNumber);
	
	return "/WEB-INF/views/fileboard/delete.jsp";
    }

}

 

deleteOk.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<c:set var = "root" value = "${pageContext.request.contextPath}"/>
<html>
<head>
<meta charset="UTF-8">
<title>ํŒŒ์ผ๋ณด๋“œ ์‚ญ์ œ ์™„๋ฃŒํŽ˜์ด์ง€</title>
</head>
<body>
	<c:if test="${check > 0}">
		<script type="text/javascript">
			alert("์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
			location.href="${root}/fileboard/list.do?pageNumber=${pageNumber}";
		</script>
	</c:if>
	<c:if test="${check == 0}">
		<script type="text/javascript">
			alert("์‚ญ์ œ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.");
			location.href="${root}/fileboard/list.do?pageNumber=${pageNumber}";
		</script>
	</c:if>
</body>
</html>

 

deleteOkCommand.java

package com.java.fileboard.command;

import java.io.File;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.java.command.Command;
import com.java.fileboard.model.BoardDao;
import com.java.fileboard.model.BoardDto;

public class DeleteOkCommand implements Command {

    @Override
    public String proRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
	int boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
	int pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
	String password = request.getParameter("password");
	logger.info(logMsg + boardNumber + "\t" + pageNumber + "\t" + password);
	
	BoardDto readBoard = BoardDao.getInstance().select(boardNumber);
	
	int check = BoardDao.getInstance().delete(boardNumber, password);
	logger.info(logMsg + check);
	
	if(check>0 && readBoard.getPath()!=null) {
	    // ํŒŒ์ผ ์ง€์šฐ๊ธฐ
	    File file = new File(readBoard.getPath());
	    if(file.exists() && file.isFile()) {
		file.delete();
	    }
	}
	
	request.setAttribute("check", check);
	request.setAttribute("pageNumber", pageNumber);
	
	return "/WEB-INF/views/fileboard/deleteOk.jsp";
    }

}

 

๋ฐ˜์‘ํ˜•
Comments