board53.sql
--board53.sql
select * from tab;
select * from board53;
create table board53(
board_num number(38) primary key
, board_name varchar2(50) not null
, board_pass varchar2(30) not null
, board_subject varchar2(100) not null
, board_content varchar2(4000) not null
, board_re_ref number
, board_re_lev number
, board_re_seq number
, board_readcount number
, board_date date
);
create sequence board53_num_seq
increment by 1 start with 1 nocache;
pom.xml - Maven configuration / Dependencies
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>sbboard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>sbboard</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
application.properties
# port
server.port=80
# view resolver
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
# oracle
spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe
spring.datasource.username=spring
spring.datasource.password=spring123
# mybatis
mybatis.config-location=classpath:mybatis-config.xml
mybatis.mapper-locations=classpath:mapper/*.xml
# DTO Alias
#mybatis.type-aliases-package=com.example.demo.model
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- Alias is not applied in Spring Boot -->
<!-- <typeAliases>
<typeAlias type="com.example.demo.model.BoardBean" alias="board"></typeAlias>
</typeAliases> -->
</configuration>
DataAccessConfig.java
package com.example.demo.model;
import java.util.Date;
import org.apache.ibatis.type.Alias;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Alias("board")
public class BoardBean {
private int board_num;
private String board_name;
private String board_pass;
private String board_subject;
private String board_content;
private int board_re_ref;
private int board_re_lev;
private int board_re_seq;
private int board_readcount;
private String board_date;
}
board.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="boardns">
<!-- Save -->
<insert id="board_insert" parameterType="board">
insert into board53
(board_num,board_name,board_pass,board_subject,
board_content,board_re_ref,board_re_lev,board_re_seq,board_readcount,board_date)
values
(board53_num_seq.nextval,#{board_name},#{board_pass},#{board_subject},
#{board_content},board53_num_seq.nextval,0,0,0,SYSDATE)
</insert>
<!-- Total posts -->
<select id="board_count" resultType="int">
select count(board_num) from board53
</select>
<!-- Post List -->
<select id="board_list" parameterType="int" resultType="board">
<![CDATA[
select * from (select rownum rnum, board.* from
(select * from board53 order by BOARD_RE_REF desc,BOARD_RE_SEQ asc) board)
where rnum >= ((#{page}-1) * 10+1) and rnum <= (#{page} * 10)
]]>
</select>
<!-- Detail Page -->
<select id="board_cont" parameterType="int" resultType="board">
select * from board53 where board_num=#{board_num}
</select>
<!-- View count +1 -->
<update id="board_hit" parameterType="int">
update board53 set
board_readcount=board_readcount+1
where board_num=#{board_num}
</update>
<!-- 게시물 수정 -->
<update id="board_edit" parameterType="board">
update board53 set
board_name=#{board_name},
board_subject=#{board_subject},
board_content=#{board_content}
where board_num=#{board_num}
</update>
<!-- Delete -->
<delete id="board_del" parameterType="int">
delete from board53 where
board_num=#{board_num}
</delete>
<!-- Reply Level -->
<update id="board_Level" parameterType="board">
update board53 set
board_re_seq=board_re_seq+1
where board_re_ref=#{board_re_ref} and
board_re_seq > #{board_re_seq}
</update>
<!-- Save Reply -->
<insert id="board_reply" parameterType="board">
insert into board53
(board_num,board_name,board_subject,board_content,
board_pass,board_re_ref,board_re_lev,board_re_seq,board_readcount,board_date)
values(board53_num_seq.nextval,#{board_name},#{board_subject},#{board_content},
#{board_pass},#{board_re_ref},#{board_re_lev},#{board_re_seq},0,SYSDATE)
</insert>
</mapper>
BoardController.java
package com.example.demo.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.demo.model.BoardBean;
import com.example.demo.service.BoardServiceImpl;
@Controller
public class BoardController {
@Autowired
private BoardServiceImpl boardService;
@RequestMapping("test.do")
public String test(){
System.out.println("Controller");
return "board/test";
}
/* New Post */
@RequestMapping(value = "/board_write.do")
public String board_write() {
return "board/board_write";
}
/* Save Post */
@RequestMapping(value = "/board_write_ok.do", method = RequestMethod.POST)
public String board_write_ok(@ModelAttribute BoardBean board)
throws Exception {
// public String board_write_ok(@RequestParam HashMap board)
// throws Exception {
boardService.insert(board);
return "redirect:/board_list.do";
}
/* Post List 게시판 목록 */
@RequestMapping(value = "/board_list.do")
public String list(Model model,
HttpServletRequest request) throws Exception {
List<BoardBean> boardlist = new ArrayList<BoardBean>();
int page = 1;
int limit = 10;
if (request.getParameter("page") != null) {
page = Integer.parseInt(request.getParameter("page"));
}
int listcount = boardService.getListCount();
boardlist = boardService.getBoardList(page);
int maxpage = (int) ((double) listcount / limit + 0.95);
int startpage = (((int) ((double) page / 10 + 0.9)) - 1) * 10 + 1;
int endpage = maxpage;
if (endpage > startpage + 10 - 1)
endpage = startpage + 10 - 1;
model.addAttribute("page", page);
model.addAttribute("startpage", startpage);
model.addAttribute("endpage", endpage);
model.addAttribute("maxpage", maxpage);
model.addAttribute("listcount", listcount);
model.addAttribute("boardlist", boardlist);
return "board/board_list";
}
@RequestMapping(value = "/board_cont.do")
public String board_cont(@RequestParam("board_num") int board_num,
@RequestParam("page") String page,
@RequestParam("state") String state,
Model model) throws Exception {
if (state.equals("cont")) {
boardService.hit(board_num);
}
BoardBean board = boardService.board_cont(board_num);
model.addAttribute("bcont", board);
model.addAttribute("page", page);
if (state.equals("cont")) {
return "board/board_cont";
} else if (state.equals("edit")) {// Edit Form
return "board/board_edit";
} else if (state.equals("del")) {// Delete Form
return "board/board_del";
} else if (state.equals("reply")) {// Reply Form
return "board/board_reply";
}
return null;
}
/* Edit */
@RequestMapping(value = "/board_edit_ok.do", method = RequestMethod.POST)
public String board_edit_ok(@ModelAttribute BoardBean b,
@RequestParam("page") String page,
Model model) throws Exception {
BoardBean board = boardService.board_cont(b.getBoard_num());
int result = 0;
if (!board.getBoard_pass().equals(b.getBoard_pass())) {// Correct password
model.addAttribute("result", result);
return "board/updateResult";
} else {
boardService.edit(b);
}
return "redirect:/board_cont.do?board_num=" + b.getBoard_num()
+ "&page=" + page + "&state=cont";
}
/* Delete */
@RequestMapping(value = "/board_del_ok.do", method = RequestMethod.POST)
public String board_del_ok(@RequestParam("board_num") int board_num,
@RequestParam("page") int page,
@RequestParam("pwd") String board_pass,
Model model) throws Exception {
BoardBean board = boardService.board_cont(board_num);
int result=0;
if (!board.getBoard_pass().equals(board_pass)) {
result = 1;
model.addAttribute("result", result);
return "board/deleteResult";
} else {
boardService.del_ok(board_num);
}
return "redirect:/board_list.do?page=" + page;
}
/* Reply */
@RequestMapping(value = "/board_reply_ok.do", method = RequestMethod.POST)
public String board_reply_ok(@ModelAttribute BoardBean b,
@RequestParam("page") String page) throws Exception {
boardService.reply_ok(b);
return "redirect:/board_list.do?page=" + page;
}
}
BoardService.java
package com.example.demo.service;
import java.util.List;
import com.example.demo.model.BoardBean;
public interface BoardService {
public void insert(BoardBean b) throws Exception;
public void hit(int board_num) throws Exception;
public BoardBean board_cont(int board_num) throws Exception;
public void edit(BoardBean b) throws Exception;
public void del_ok(int board_num) throws Exception;
public void reply_ok(BoardBean b) throws Exception;
public int getListCount() throws Exception;
public List getBoardList(int page) throws Exception;
}
BoardServiceImpl.java
package com.example.demo.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.demo.dao.BoardDAOImpl;
import com.example.demo.model.BoardBean;
@Service
public class BoardServiceImpl implements BoardService{
@Autowired
private BoardDAOImpl boardDao;
public void insert(BoardBean b) throws Exception {
boardDao.insertBoard(b);
}
// Total Post
@Override
public int getListCount() throws Exception {
return boardDao.getListCount();
}
// Post List
@Override
public List getBoardList(int page) throws Exception {
// TODO Auto-generated method stub
return boardDao.getBoardList(page);
}
/* View count +1 */
public void hit(int board_num) throws Exception {
boardDao.boardHit(board_num);
}
/* Detail */
public BoardBean board_cont(int board_num) throws Exception {
BoardBean board = boardDao.getBoardCont(board_num);
return board;
}
/* Edit */
public void edit(BoardBean b) throws Exception {
boardDao.boardEdit(b);
}
/* Delete */
public void del_ok(int board_num) throws Exception{
boardDao.boardDelete(board_num);
}
/* Reply */
public void reply_ok(BoardBean b) throws Exception {
boardDao.refEdit(b);
b.setBoard_re_lev(b.getBoard_re_lev() + 1);
b.setBoard_re_seq(b.getBoard_re_seq() + 1);
boardDao.boardReplyOk(b);
}
}
BoardDao.java
package com.example.demo.dao;
import java.util.List;
import com.example.demo.model.BoardBean;
public interface BoardDao {
public void insertBoard(BoardBean b) throws Exception;
public List<BoardBean> getBoardList(int page) throws Exception;
public int getListCount() throws Exception;
public BoardBean getBoardCont(int board_num) throws Exception;
public void boardHit(int board_num) throws Exception;
public void boardEdit(BoardBean b) throws Exception;
public void boardDelete(int board_num) throws Exception;
public void refEdit(BoardBean b) throws Exception;
public void boardReplyOk(BoardBean b) throws Exception;
}
BoardDAOImpl.java
package com.example.demo.dao;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.example.demo.model.BoardBean;
@Repository
public class BoardDAOImpl implements BoardDao{
@Autowired
private SqlSession session;
public void insertBoard(BoardBean b) throws Exception {
session.insert("boardns.board_insert", b);
}
/* Post List */
public List<BoardBean> getBoardList(int page) throws Exception {
List<BoardBean> list = session.selectList("boardns.board_list", page);
return list;
}
/* Total Post */
public int getListCount() throws Exception {
int count = 0;
count = ((Integer) session.selectOne("boardns.board_count")).intValue();
return count;
}
/* Detail */
public BoardBean getBoardCont(int board_num) throws Exception {
return (BoardBean) session.selectOne("boardns.board_cont",board_num);
}
/* View Count + 1 */
public void boardHit(int board_num) throws Exception {
session.update("boardns.board_hit", board_num);
}
/* Edit */
public void boardEdit(BoardBean b) throws Exception {
session.update("boardns.board_edit", b);
}
/* Delete */
public void boardDelete(int board_num) throws Exception {
session.delete("boardns.board_del", board_num);
}
/* Reply */
public void refEdit(BoardBean b) throws Exception {
session.update("boardns.board_Level", b);
}
/* Reply Save */
public void boardReplyOk(BoardBean b) throws Exception {
session.insert("boardns.board_reply", b);
}
}
boad_list.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.example.demo.model.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Post list</title>
<link rel="stylesheet" href="./css/bbs.css" type="text/css">
</head>
<body>
<!-- List -->
<div id="bbslist_wrap">
<h2 class="bbslist_title">List</h2>
<div id="bbslist_c">Total Posts : ${listcount}</div>
<table id="bbslist_t">
<tr align="center" valign="middle" bordercolor="#333333">
<td style="font-family: Tahoma; font-size: 11pt;" width="8%"
height="26">
<div align="center">Number</div>
</td>
<td style="font-family: Tahoma; font-size: 11pt;" width="47%">
<div align="center">Title</div>
</td>
<td style="font-family: Tahoma; font-size: 11pt;" width="14%">
<div align="center">Writer</div>
</td>
<td style="font-family: Tahoma; font-size: 11pt;" width="17%">
<div align="center">Date</div>
</td>
<td style="font-family: Tahoma; font-size: 11pt;" width="14%">
<div align="center">View</div>
</td>
</tr>
<c:set var="num" value="${listcount-(page-1)*10}"/>
<!-- forEach Tag -->
<c:forEach var="b" items="${boardlist}">
<tr align="center" valign="middle" bordercolor="#333333"
onmouseover="this.style.backgroundColor='F8F8F8'"
onmouseout="this.style.backgroundColor=''">
<td height="23" style="font-family: Tahoma; font-size: 10pt;">
<!-- Number -->
<c:out value="${num}"/>
<c:set var="num" value="${num-1}"/>
</td>
<td style="font-family: Tahoma; font-size: 10pt;">
<div align="left">
<c:if test="${b.board_re_lev != 0}">
<c:forEach var="k" begin="1" end="${b.board_re_lev}">
</c:forEach>
<img src="./images/AnswerLine.gif">
</c:if>
<!-- Title -->
<a href="board_cont.do?board_num=${b.board_num}&page=${page}&state=cont">
${b.board_subject}
</a>
</div>
</td>
<td style="font-family: Tahoma; font-size: 10pt;">
<div align="center">${b.board_name}</div>
</td>
<td style="font-family: Tahoma; font-size: 10pt;">
<div align="center">${b.board_date}</div>
</td>
<td style="font-family: Tahoma; font-size: 10pt;">
<div align="center">${b.board_readcount}</div>
</td>
</tr>
</c:forEach>
</table>
<div id="bbslist_paging">
<c:if test="${page <=1 }">
[Prev]
</c:if>
<c:if test="${page > 1 }">
<a href="board_list.do?page=${page-1}">[Prev]</a>
</c:if>
<c:forEach var="a" begin="${startpage}" end="${endpage}">
<c:if test="${a == page }">
[${a}]
</c:if>
<c:if test="${a != page }">
<a href="board_list.do?page=${a}">[${a}]</a>
</c:if>
</c:forEach>
<c:if test="${page >= maxpage }">
[Next]
</c:if>
<c:if test="${page < maxpage }">
<a href="board_list.do?page=${page+1}">[Next]</a>
</c:if>
</div>
<div id="bbslist_w">
<input type="button" value="New Post" class="input_button"
onclick="location='board_write.do?page=${page}'">
</div>
</div>
</body>
</html>
board_write.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>New Post</title>
<link rel="stylesheet" type="text/css" href="./css/bbs.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="./js/board.js"></script>
</head>
<body>
<div id="bbswrite_wrap">
<h2 class="bbswrite_title">New Post</h2>
<form method="post" action="board_write_ok.do" onSubmit="return board_check()">
<table id="bbswrite_t">
<tr>
<th>Writer</th>
<td>
<input name="board_name" id="board_name" size="14" class="input_box" />
</td>
</tr>
<tr>
<th>Password</th>
<td>
<input type="password" name="board_pass" id="board_pass" size="14"
class="input_box" />
</td>
</tr>
<tr>
<th>Title</th>
<td>
<input name="board_subject" id="board_subject" size="40"
class="input_box" />
</td>
</tr>
<tr>
<th>Content</th>
<td>
<textarea name="board_content" id="board_content" rows="8" cols="50"
class="input_box"></textarea>
</td>
</tr>
</table>
<div id="bbswrite_menu">
<input type="submit" value="Submit" class="input_button" />
<input type="reset" value="Cancel" class="input_button"
onclick="$('#board_name').focus();" />
</div>
</form>
</div>
</body>
</html>
board_cont.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Post</title>
<link rel="stylesheet" type="text/css" href="./css/board.css" />
</head>
<body>
<div id="boardcont_wrap">
<h2 class="boardcont_title">Post</h2>
<table id="boardcont_t">
<tr>
<th>Title</th>
<td>${bcont.board_subject}</td>
</tr>
<tr>
<th>Content</th>
<td>
<%-- ${board_cont} --%>
<pre>${bcont.board_content}</pre>
</td>
</tr>
<tr>
<th>View</th>
<td>${bcont.board_readcount}</td>
</tr>
</table>
<div id="boardcont_menu">
<input type="button" value="Edit" class="input_button"
onclick="location='board_cont.do?board_num=${bcont.board_num}&page=${page}&state=edit'" />
<input type="button" value="Delete" class="input_button"
onclick="location='board_cont.do?board_num=${bcont.board_num}&page=${page}&state=del'" />
<input type="button" value="Reply" class="input_button"
onclick="location='board_cont.do?board_num=${bcont.board_num}&page=${page}&state=reply'" />
<input type="button" value="List" class="input_button"
onclick="location='board_list.do?page=${page}'" />
</div>
</div>
</body>
</html>
board_reply.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Reply</title>
<link rel="stylesheet" type="text/css" href="./css/board.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="./js/board.js"></script>
</head>
<body>
<div id="boardreply_wrap">
<h2 class="boardreply_title">Reply</h2>
<form method="post" action="board_reply_ok.do">
<input type="hidden" name="board_num" value="${bcont.board_num}" />
<input type="hidden" name="board_re_ref" value="${bcont.board_re_ref}" />
<input type="hidden" name="board_re_lev" value="${bcont.board_re_lev}" />
<input type="hidden" name="board_re_seq" value="${bcont.board_re_seq}" />
<input type="hidden" name="page" value="${page}" />
<table id="boardreply_t">
<tr>
<th>Writer</th>
<td>
<input name="board_name" id="board_name" size="14" class="input_box" />
</td>
</tr>
<tr>
<th>Password</th>
<td>
<input type="password" name="board_pass" id="board_pass"
size="14" class="input_box" />
</td>
</tr>
<tr>
<th>Title</th>
<td>
<input name="board_subject" id="board_subject" size="40"
class="input_box" value="Re:${bcont.board_subject}" />
</td>
</tr>
<tr>
<th>Content</th>
<td>
<textarea name="board_content" id="board_content" rows="8"
cols="50" class="input_box" ></textarea>
</td>
</tr>
</table>
<div id="boardreply_menu">
<input type="submit" value="Submit" class="input_button" />
<input type="reset" value="Cancel" class="input_button"
onclick="$('#board_name').focus();" />
</div>
</form>
</div>
</body>
</html>
board_edit.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Edit</title>
<link rel="stylesheet" type="text/css" href="./css/bbs.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="./js/board.js"></script>
</head>
<body>
<div id="bbswrite_wrap">
<h2 class="bbswrite_title">Edit Post</h2>
<form method="post" action="board_edit_ok.do" onSubmit="return board_check()">
<input type="hidden" name="board_num" value="${bcont.board_num}" />
<input type="hidden" name="page" value="${page}" />
<table id="bbswrite_t">
<tr>
<th>Writer</th>
<td>
<input name="board_name" id="board_name" size="14" class="input_box"
value="${bcont.board_name}" />
</td>
</tr>
<tr>
<th>Password</th>
<td>
<input type="password" name="board_pass" id="board_pass" size="14"
class="input_box" />
</td>
</tr>
<tr>
<th>Title</th>
<td>
<input name="board_subject" id="board_subject" size="40"
class="input_box" value="${bcont.board_subject}" />
</td>
</tr>
<tr>
<th>Content</th>
<td>
<textarea name="board_content" id="board_content" rows="8" cols="50"
class="input_box">${bcont.board_content}</textarea>
</td>
</tr>
</table>
<div id="bbswrite_menu">
<input type="submit" value="Edit" class="input_button" />
<input type="reset" value="Cancel" class="input_button"
onclick="$('#board_name').focus();" />
</div>
</form>
</div>
</body>
</html>
board_del.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Delete Post</title>
<link rel="stylesheet" type="text/css" href="./css/board.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
function del_check(){
if($.trim($("#pwd").val())==""){
alert("Enter the password!");
$("#pwd").val("").focus();
return false;
}
}
</script>
</head>
<body>
<div id="boarddel_wrap">
<h2 class="boarddel_title">Delete</h2>
<form method="post" action="board_del_ok.do"
onsubmit="return del_check()">
<input type="hidden" name="board_num" value="${bcont.board_num}" />
<input type="hidden" name="page" value="${page}" />
<table id="boarddel_t">
<tr>
<th>Password</th>
<td>
<input type="password" name="pwd" id="pwd" size="14"
class="input_box" />
</td>
</tr>
</table>
<div id="boarddel_menu">
<input type="submit" value="Delete" class="input_button" />
<input type="reset" value="Cancel" class="input_button"
onclick="$('#pwd').focus();" />
</div>
</form>
</div>
</body>
</html>