Advertisement
hyunjeong

Untitled

Aug 29th, 2019
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <%@ page import ="java.io.PrintWriter" %>
  4. <%@ page import ="bbs.Bbs" %>
  5. <%@ page import ="bbs.BbsDAO" %>
  6.  
  7. <html>
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  10. <title>JSP 게시판 웹사이트</title>
  11. <link rel="stylesheet" href="css/bootstrap.css">
  12. </head>
  13. <body>
  14. <%
  15. String userId = null;
  16. if(session.getAttribute("userId") != null ) {
  17. userId = (String) session.getAttribute("userId");
  18. }
  19. int bbsId = -1;
  20. if(request.getParameter("bbsId") != null ) {
  21. bbsId= Integer.parseInt(request.getParameter("bbsId"));
  22. }
  23. if(bbsId == -1) {
  24. PrintWriter script = response.getWriter();
  25. script.println("<script>");
  26. script.println("alert('유효하지 않은 글입니다.')");
  27. script.println("location.href= 'bbs.jsp' ");
  28. script.println("</script>");
  29. }
  30. Bbs bbs = new BbsDAO().getBbs(bbsId);
  31. %>
  32. <nav class= "navbar navbar-default">
  33. <div class="navbar-header">
  34. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
  35. data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  36. <span class="icon-bar"></span>
  37. <span class="icon-bar"></span>
  38. <span class="icon-bar"></span>
  39. </button>
  40. <a class="navbar-brand" href="login.jsp">JSP게시판 웹 사이트</a>
  41. </div>
  42. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  43. <ul class="nav navbar-nav">
  44. <li><a href="main.jsp">메인</a></li>
  45. <li class="active"><a href="bbs.jsp">게시판</a></li>
  46. </ul>
  47. <%
  48. if(userId == null) {
  49. %>
  50. <ul class="nav navbar-nav navbar-right">
  51. <li class="dropdown">
  52. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
  53. aria-haspopup="true" aria-expanded="false" >
  54. 접속하기<span class=caret></span>
  55. </a>
  56. <ul class="dropdown-menu">
  57. <li><a href="login.jsp">로그인</a></li>
  58. <li><a href="join.jsp">회원가입</a></li>
  59. </ul>
  60. </li>
  61. </ul>
  62. <%
  63. } else {
  64. %>
  65. <ul class="nav navbar-nav navbar-right">
  66. <li class="dropdown">
  67. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
  68. aria-haspopup="true" aria-expanded="false" >
  69. 회원관리<span class=caret></span>
  70. </a>
  71. <ul class="dropdown-menu">
  72.  
  73. <li><a href="logoutAction.jsp">로그아웃</a></li>
  74. </ul>
  75. </li>
  76. </ul>
  77. <%
  78. }
  79. %>
  80. </div>
  81. </nav>
  82. <div class="container">
  83. <div class="row">
  84. <table class="table table-striped" style="text-align:center; border:1px solid #dddddd">
  85. <thead>
  86. <tr>
  87. <th colspan="3" style="background-color: #eeeeee; text-align:center;">게시판 글보기</th>
  88. </tr>
  89. </thead>
  90. <tbody>
  91. <tr>
  92. <td style="width:20%">글 제목</td>
  93. <td colspan="2"><%= bbs.getBbsTitle().replaceAll(" ", "&nbsp;").replaceAll("<","&lt").replaceAll(" ","&gt")
  94. .replaceAll("\n","</br>") %></td>
  95. </tr>
  96. <tr>
  97. <td>작성자</td>
  98. <td colspan="2"><%= bbs.getUserId() %></td>
  99. </tr>
  100. <tr>
  101. <td>작성시간</td>
  102. <td colspan="2"><%= bbs.getBbsDate().substring(0,11)+
  103. bbs.getBbsDate().substring(11,13)+ "시 "+ bbs.getBbsDate().substring(14,16)+ "분" %></td>
  104. </tr>
  105. <tr>
  106. <td>내용</td>
  107. <td colspan="2" style="min-height:200px; text-align:left;"><%=bbs.getBbsContent().replaceAll(" ", "&nbsp;")
  108. .replaceAll("<","&lt").replaceAll(" ","&gt").replaceAll("\n","</br>") %></td>
  109. </tr>
  110. </tbody>
  111. </table>
  112. <a href="bbs.jsp" class="btn btn-primary">목록</a>
  113. <%
  114. if(userId != null && userId.equals(bbs.getUserId())) {
  115. %>
  116. <a href="update.jsp?bbsId=<%=bbsId %>" class="btn btn-primary">수정</a>
  117. <a onclick="return confirm('정말로 삭제하시겠습니까?')" href="deleteAction.jsp?bbsId=<%=bbsId %>" class="btn btn-primary">삭제</a>
  118. <%
  119. }
  120. %>
  121. </div>
  122. </div>
  123. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  124. <script src="js/bootstrap.js"></script>
  125. </body>
  126. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement