오늘은 BoardWriteForm.jsp와 BoardDAO클래스를 만들어 보았다.
BoardWriteForm.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>
<center>
<h2>게시글 쓰기 </h2>
<form action="BoardWriteProc.jsp" method="post">
<table width ="600" border="1" bordercolor="gray" bgcolor="skyblue">
<tr height="40">
<td align="center" width="150">작성자</td>
<td align="center" width="450"> <input type="text" name="writer" size="60"> </td>
</tr>
<tr height="40">
<td align="center" width="150">제목</td>
<td align="center" width="450"> <input type="text" name="subject" size="60"> </td>
</tr>
<tr height="40">
<td align="center" width="150">이메일</td>
<td align="center" width="450"> <input type="email" name="email" size="60"> </td>
</tr>
<tr height="40">
<td align="center" width="150">비밀번호</td>
<td align="center" width="450"> <input type="password" name="password" size="60"> </td>
</tr>
<tr height="40">
<td align="center" width="150">글내용 </td>
<td align="center" width="450"> <textarea rows="10" cols="50" name="content" size="60"></textarea> </td>
</tr>
<tr height="40">
<td align="center" colspan="2">
<input type="submit" value="글쓰기">
<input type="reset" value="다시작성">
<button onclick="location.href='BoardList.jsp' ">전체게시글보기</button>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
BoardDAO.class
package db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
public class BoardDAO {
Connection con;
PreparedStatement pstmt;
ResultSet rs;
//데이터베이스의 커넥션풀을 사용하도록 설정하는 메소드
public void getCon() {
try {
Context initctx = new InitialContext();
Context envctx =(Context) initctx.lookup("java:comp/env");
DataSource ds = (DataSource)envctx.lookup("jdbc/pool");
//datascource
con = ds.getConnection();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
위 코드들을 잘 보고 이해하자.!
'웹 프로그래밍(풀스택-->java) > 웹프로그래밍(백엔드-->java)' 카테고리의 다른 글
36. Jsp 게시판 - BoardList 글 목록 보기 (0) | 2021.12.06 |
---|---|
35. Jsp 게시판 - BoardWriteProc, 게시글 입력 (0) | 2021.12.05 |
33. Jsp 게시판 - 테이블 설정, 빈클래스,Dao클래스 설정 (0) | 2021.12.05 |
32. Jsp 게시판 - 시스템구조 (0) | 2021.12.05 |
31. Jsp Cookie & Sessions 5&6 (0) | 2021.12.03 |