오늘은
요즘 진로에 대해서 고민이 깊어지고 있습니다
프론트엔드 쪽으로 진로를 정했는데
프론트엔드도 하나만 있는게 아닌 것 같더군요
친구의 정보에 의하면 스크립트를 짜면서 기능을 구현하는 공부를
더 하면서 백엔드도 가져가는 풀스택을 노려볼 수도 있고
프론트에 프론트를 더해 3D 과정을 거쳐 프론트엔드분야를
깊이 파고드는 선택을 할 수도 있다고 하여서
과연 어느 분야가 나한테 더 잘 맞을까 고민을 하고 있습니다
회원 커뮤니티 프로젝트
<게시판>
( 1. 게시글 목록 - /boardlist.do (-> /board/boardlist.jsp)
2. 글쓰기 폼 페이지 - /writeform.do (->/board/writeform.jsp)
세션 적용 = 로그인 된 사용자만 접속 허용
3. 글쓰기 - /write.do )
4. 글 상세보기 - /boardview.do (-> /board/boardview.jsp)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<script src="https://kit.fontawesome.com/bf7b37fa88.js" crossorigin="anonymous"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>글 상세보기</title>
<link rel="stylesheet" href="resources/css/style.css">
</head>
<body>
<jsp:include page="../header.jsp"/>
<div id="container">
<section id="board_view">
<h2>글 상세보기</h2>
<table>
<tbody>
<tr>
<td>
<input type="text" name="title" value="${board.title}" readonly>
</td>
</tr>
<tr>
<td>
<textarea rows="7" cols="100" name="content" readonly>${board.content}</textarea>
</td>
</tr>
<tr>
<td>
<c:if test="${sessionId eq board.id}">
<a href="/updateboardform.do?bno=${board.bno}">
<button type="button" class="ud_btn">수정</button>
</a>
<a href="/deleteboard.do?bno=${board.bno}" onclick="return confirm('정말로 삭제하시겠습니까?')">
<button type="button" class="ud_btn">삭제</button>
</a>
</c:if>
<a href="/boardlist.do">
<button type="button" class="list_btn">목록</button>
</a>
</td>
</tr>
</tbody>
</table>
</section>
</div>
<jsp:include page="../footer.jsp"/>
</body>
</html>
조회수 1 증가 - rs.getInt(hit) + 1
5. 글 삭제 - /deleteboard.do (-> /boardlist.do)
else if(command.equals("/deleteboard.do")) {
// 글 제목 클릭시 요청되는 글 번호 받기
int bno = Integer.parseInt(request.getParameter("bno"));
// 삭제 처리
bDAO.deleteboard(bno);
nextPage = "/boardlist.do";
}
6. 글 수정 - /updateboardform.do (-> /borad/updateboardform.jsp)
else if(command.equals("/updateboardform.do")) {
// 수정을 위해서 게시글 가져오기
int bno = Integer.parseInt(request.getParameter("bno"));
// 게시글 1건 가져오기
Board board = bDAO.getBoard(bno);
// 모델 생성
request.setAttribute("board", board);
nextPage = "/board/updateboardform.jsp";
}
7. 글 수정 처리 - /updateboard.do (-> /boardlist.do)
else if(command.equals("/updateboard.do")) {
// 게시글 제목, 내용을 파라미터로 받음
int bno = Integer.parseInt(request.getParameter("bno"));
String title = request.getParameter("title");
String content = request.getParameter("content");
// 수정 처리 메서드
Board b = new Board();
b.setTitle(title);
b.setContent(content);
b.setBno(bno);
bDAO.updateboard(b);
nextPage = "/boardlist.do";
}
<댓글>
<!-- 댓글 영역 -->
<h3>댓글 <i class="fa-regular fa-comment-dots"></i></h3>
<c:forEach items="${replyList}" var="reply">
<div class="reply">
<p>작성자: ${reply.replyer}</p>
<p>${reply.rcontent}</p>
<p>
<span>(작성일: <fmt:formatDate value ="${reply.rdate}" pattern="yyyy-MM-dd HH:mm:ss a"/>)</span>
<c:if test="${sessionId eq reply.replyer}">
<a href="/updatereplyform.do?bno=${board.bno}&rno=${reply.rno}">수정</a>
| <a href="/deletereply.do?bno=${board.bno}&rno=${reply.rno}" onclick="return confirm('정말로 삭제하시겠습니까?')">삭제</a>
</c:if>
</p>
</div>
</c:forEach>
<!-- 댓글 등록 -->
<form action="/insertreply.do" id="replyform">
<input type="hidden" name="bno" value="${board.bno}">
<input type="hidden" name="replyer" value="${sessionId}">
<p>
<textarea rows="4" cols="50" name="rcontent"
placeholder="댓글을 남겨주세요"></textarea>
</p>
<c:if test="${not empty sessionId}">
<button type="submit">등록</button>
</c:if>
</form>
<!-- 로그인한 사용자만 댓글 등록 가능 -->
<c:if test="${empty sessionId}">
<div class="replylogin">
<a href="/loginform.do">
<i class="fa-solid fa-user"></i>로그인한 사용자만 댓글 등록이 가능합니다
</a>
</div>
</c:if>
1. 댓글 목록 - /boardview.do
public List<Reply> getReplyList(int bno){
List<Reply> replyList = new ArrayList<Reply>();
try {
conn = JDBCUtil.getConnection();
String sql = "SELECT * FROM reply WHERE bno= ? ORDER BY rdate";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, bno);
// sql 처리
rs = pstmt.executeQuery();
while(rs.next()) {
// 빈 댓글을 생성해서 db에서 정보를 가져와서 세팅
Reply r = new Reply();
r.setRno(rs.getInt("rno"));
r.setBno(rs.getInt("bno"));
r.setRcontent(rs.getString("rcontent"));
r.setReplyer(rs.getString("replyer"));
r.setRdate(rs.getTimestamp("rdate"));
r.setRupdate(rs.getTimestamp("rupdate"));
// ArrayList에 댓글을 추가
replyList.add(r);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(conn, pstmt, rs);
}
return replyList;
}
2. 댓글 등록 - /insertboard.do (-> /boardview.do?bno=${b.bno})
public void insertreply(Reply r) {
try {
conn = JDBCUtil.getConnection();
String sql = "INSERT INTO reply (rno, bno, rcontent, replyer) "
+ "VALUES (seq_rno.NEXTVAL, ?, ?, ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, r.getBno());
pstmt.setString(2, r.getRcontent());
pstmt.setString(3, r.getReplyer());
// sql 처리
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(conn, pstmt);
}
}
if(command.equals("/insertreply.do")) {
// 댓글 폼 데이터 받기
int bno = Integer.parseInt(request.getParameter("bno"));
String rcontent = request.getParameter("rcontent");
String replyer = request.getParameter("replyer");
// 댓글 등록 처리
Reply r = new Reply();
r.setBno(bno);
r.setRcontent(rcontent);
r.setReplyer(replyer);
rDAO.insertreply(r);
}
3. 댓글 삭제 - /deletereply.do (-> /boardview.do>bno=${b.bno})
public void deletereply(int rno) {
try {
conn = JDBCUtil.getConnection();
String sql = "DELETE FROM reply WHERE rno = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, rno);
// sql 처리
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(conn, pstmt);
}
}
else if(command.equals("/deletereply.do")) {
int rno = Integer.parseInt(request.getParameter("rno"));
// 삭제 처리 메서드 호출
rDAO.deletereply(rno);
}
2023. 12. 01 (금)
프로그래머 도전기 79일차 (0) | 2023.12.04 |
---|---|
프로그래머 도전기 78일차 (0) | 2023.12.02 |
프로그래머 도전기 76일차 (0) | 2023.11.30 |
프로그래머 도전기 75일차 (2) | 2023.11.28 |
프로그래머 도전기 74일차 (1) | 2023.11.27 |