bbs/view.jsp
페이지 정보
본문
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/header.jsp" %>
<%
String code = request.getParameter("code"); //데이타베이스 게시판 테이블명
String uid = request.getParameter("uid");
//검색 관련
String field = request.getParameter("field");
String search = request.getParameter("search");
//페이징 관련
String page_now = request.getParameter("page_now");
//게시판 타이틀
String bbs_title = "";
if(code.equals("notice")){
bbs_title = "공지게시판";
}else if(code.equals("free")){
bbs_title = "자유게시판";
}else if(code.equals("gallery")){
bbs_title = "갤러리게시판";
}else if(code.equals("qna")){
bbs_title = "QnA게시판";
}
%>
<%
//조회수 +1
String sql_count="update "+code+" set ref = ref + 1 where uid="+uid;
Connection conn_count=DriverManager.getConnection(url, user, password);
Statement stmt_count=conn_count.createStatement();
stmt_count.executeUpdate(sql_count);
stmt_count.close();
conn_count.close();
//view(상세보기)
String sql="select * from "+code+" where uid="+uid;
Connection conn=DriverManager.getConnection(url, user, password);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
//전역변수
String id = "";
String name = "";
String gongji = "";
String subject = "";
String comment = "";
String signdate = "";
String ref = "";
String file1 = "";
if(rs.next()){
id = rs.getString("id");
name = rs.getString("name");
gongji = rs.getString("gongji");
subject = rs.getString("subject");
comment = rs.getString("comment");
signdate = rs.getString("signdate");
ref = rs.getString("ref");
file1 = rs.getString("file1");
}
rs.close();
stmt.close();
conn.close();
if(gongji.equals("3")){ //비밀글
if((session_level != null && session_level.equals("10")) || (session_id != null && session_id.equals(id))){
//관리자 or 작성자
}else{
%>
<script>
alert("읽을 권한이 없습니다.");
history.back();
</script>
<%
}
}
%>
<table width=100% height=50 border=0>
<tr>
<td align=center style="color:#777;font-size:14px;font-weight:bold;">[<%=bbs_title %>]_상세보기</td>
</tr>
</table>
<center>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr height=26>
<td colspan=3 height=20 width=100% align=right>●글쓴이:<%=name%> ●작성일:<%=signdate%> ●조회:<%=ref%></td>
</tr>
<tr><td colspan=3 height=1 width=100% bgcolor=#d1dee2></td></tr>
<tr height=26 bgcolor="#eee" align="center">
<td colspan=3><%=subject%></td>
</tr>
<tr><td colspan=3 height=1 width=100% bgcolor=#d1dee2></td></tr>
<%
//commnet 개행처리
pageContext.setAttribute("cmt", comment);
pageContext.setAttribute("LF", "\n");
%>
<tr>
<td colspan=3 width=100% style="padding:5px 0px 7px 0px">${fn:replace(cmt, LF, '<br>')}</td>
</tr>
<tr><td colspan=3 height=1 width=100% bgcolor=#d1dee2></td></tr>
<%if(!file1.equals("")){ //첨부파일 존재 %>
<tr height=26>
<td colspan=3>● 첨부 : <a href="/upload/<%=file1 %>" download><%=file1 %></a></td>
</tr>
<tr><td colspan=3 height=1 width=100% bgcolor=#d1dee2></td></tr>
<%} %>
</table>
<br>
<!-- 댓글 부분 시작 -->
<br>
<div style="width:700px;height:22px;text-align:left;font-weight:bold;color:#97b1ec">●댓글</div>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr><td colspan=3 height=1 width=100% bgcolor=#97b1ec></td></tr>
<%
//댓글 목록
String sql_comment="select * from comment where tb_table='"+code+"' and tb_uid="+uid;
Connection conn_comment=DriverManager.getConnection(url, user, password);
Statement stmt_comment=conn_comment.createStatement();
ResultSet rs_comment=stmt_comment.executeQuery(sql_comment);
int i=0;
while(rs_comment.next()){
int com_uid = rs_comment.getInt("uid");
String tb_id = rs_comment.getString("tb_id");
%>
<tr height=26>
<td width=90><%=rs_comment.getString("tb_name") %></td>
<td width=510 style="padding:5px 0px 5px 0px;">
<%=rs_comment.getString("tb_comment") %>
<%
//작성자 or 관리자 삭제
if((session_id != null && session_id.equals(tb_id)) || (session_level != null && session_level.equals("10"))){
%>
<a href='comment_delete.jsp?code=<%=code%>&uid=<%=uid%>&field=<%=field%>&search=<%=search%>&page_now=<%=page_now%>&com_uid=<%=com_uid%>'>
<img src='img/comment_del.gif'></a>
<%
}
%>
</td>
<td width=100 align=right><%=rs_comment.getString("tb_date") %></td>
</tr>
<tr><td colspan=3 height=1 width=100% bgcolor=#97b1ec></td></tr>
<%
i++;
}
rs_comment.close();
stmt_comment.close();
conn_comment.close();
if(i == 0){ //출력할 내용이 없다면
%>
<tr><td colspan=3 align=center height=40>등록된 댓글이 없습니다.</td></tr>
<tr><td colspan=3 height=1 width=100% bgcolor=#97b1ec></td></tr>
<%
}
%>
</table>
<form action="comment_insert.jsp" method="post" onsubmit="return send()">
<input type="hidden" name="code" value="<%=code %>">
<input type="hidden" name="uid" value="<%=uid %>">
<input type="hidden" name="field" value="<%=field %>">
<input type="hidden" name="search" value="<%=search %>">
<input type="hidden" name="page_now" value="<%=page_now %>">
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr height=30>
<td width=610><input id="view_comment" name="view_comment" style="width:99%"></td>
<td width=90 align=right>
<%if(session_id != null){ %>
<button>댓글등록</button>
<%}else{ %>
<input type="button" onclick="javascript:alert('로그인 후 사용 가능합니다..')" value="댓글등록">
<%} %>
</td>
</tr>
<tr><td colspan=2 height=1 width=100% bgcolor=#97b1ec></td></tr>
</table>
</form>
<script>
function send(){
if(!view_comment.value){
alert("댓글 내용을 입력하세요.");
view_comment.focus();
return false;
}
}
</script>
<br>
<!-- 댓글 부분 끝 -->
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><a href="list.jsp?code=<%=code%>&field=<%=field%>&search=<%=search%>&page_now=<%=page_now%>">[목록]</a></td>
<td align=right>
<a href="modify.jsp?code=<%=code%>&uid=<%=uid%>&field=<%=field%>&search=<%=search%>&page_now=<%=page_now%>">[수정]</a>
<a href="delete.jsp?code=<%=code%>&uid=<%=uid%>">[삭제]</a>
</td>
</tr>
</table>
<br>
</center>
<%@ include file="/include/footer.jsp" %>
- 이전글● ⑧ bbs 게시판 ( 댓글 추가 ) 23.03.16
- 다음글bbs/comment_insert.jsp 23.03.16
댓글목록
등록된 댓글이 없습니다.