hyunjeong

Untitled

Aug 29th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 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.BbsDAO" %>
  5. <%@ page import = "bbs.Bbs" %>
  6. <%@ page import = "java.util.ArrayList" %>
  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. <style>
  13. a, a:hover {color:#000; text-decoration:none;}
  14. </style>
  15. </head>
  16. <body>
  17. <%
  18. String userId = null;
  19. if(session.getAttribute("userId") != null ) {
  20. userId = (String) session.getAttribute("userId");
  21. }
  22.  
  23. int pageNumber =1;
  24. if (request.getParameter("pageNumber")!= null) {
  25. pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
  26. }
  27. %>
  28. <nav class= "navbar navbar-default">
  29. <div class="navbar-header">
  30. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
  31. data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  32. <span class="icon-bar"></span>
  33. <span class="icon-bar"></span>
  34. <span class="icon-bar"></span>
  35. </button>
  36. <a class="navbar-brand" href="login.jsp">JSP게시판 웹 사이트</a>
  37. </div>
  38. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  39. <ul class="nav navbar-nav">
  40. <li><a href="main.jsp">메인</a></li>
  41. <li class="active"><a href="bbs.jsp">게시판</a></li>
  42. </ul>
  43. <%
  44. if(userId == null) {
  45. %>
  46. <ul class="nav navbar-nav navbar-right">
  47. <li class="dropdown">
  48. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
  49. aria-haspopup="true" aria-expanded="false" >
  50. 접속하기<span class=caret></span>
  51. </a>
  52. <ul class="dropdown-menu">
  53. <li><a href="login.jsp">로그인</a></li>
  54. <li><a href="join.jsp">회원가입</a></li>
  55. </ul>
  56. </li>
  57. </ul>
  58. <%
  59. } else {
  60. %>
  61. <ul class="nav navbar-nav navbar-right">
  62. <li class="dropdown">
  63. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
  64. aria-haspopup="true" aria-expanded="false" >
  65. 회원관리<span class=caret></span>
  66. </a>
  67. <ul class="dropdown-menu">
  68.  
  69. <li><a href="logoutAction.jsp">로그아웃</a></li>
  70. </ul>
  71. </li>
  72. </ul>
  73. <%
  74. }
  75. %>
  76. </div>
  77. </nav>
  78. <div class="container">
  79. <div class="row">
  80. <table class="table table-striped" style="text-align:center; border:1px solid #dddddd" >
  81. <thead>
  82. <tr>
  83. <th style="background-color: #eeeeee; text-align:center;">번호</th>
  84. <th style="background-color: #eeeeee; text-align:center;">제목</th>
  85. <th style="background-color: #eeeeee; text-align:center;">작성자</th>
  86. <th style="background-color: #eeeeee; text-align:center;">작성일</th>
  87. </tr>
  88. </thead>
  89. <tbody>
  90. <%
  91. BbsDAO bbsDAO = new BbsDAO();
  92. ArrayList <Bbs> list = bbsDAO.getList(pageNumber);
  93. for (int i =0; i<list.size(); i++) {
  94. %>
  95. <tr>
  96. <td><%= list.get(i).getBbsId()%></td>
  97. <td><a href="view.jsp?bbsId=<%= list.get(i).getBbsId() %>"><%= list.get(i).getBbsTitle() %></a></td>
  98. <td><%= list.get(i).getUserId() %></td>
  99. <td><%= list.get(i).getBbsDate().substring(0,11)+
  100. list.get(i).getBbsDate().substring(11,13)+ "시 "+ list.get(i).getBbsDate().substring(14,16)+ "분" %></td>
  101. </tr>
  102. <%
  103. }
  104. %>
  105. </tbody>
  106. </table>
  107. <%
  108. if(pageNumber != 1) {
  109. %>
  110. <a href="bbs.jsp?pageNumber=<%=pageNumber-1 %>" class="btn btn-success btn-arrow-left">이전</a>
  111.  
  112. <%
  113. } if(bbsDAO.nextPage(pageNumber+1)) {
  114. %>
  115. <a href="bbs.jsp?pageNumber=<%=pageNumber+1 %>" class="btn btn-success btn-arrow-left">다음</a>
  116. <%
  117. }
  118. %>
  119. <a href="write.jsp" class="btn btn-primary pull-right">글쓰기</a>
  120. </div>
  121. </div>
  122. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  123. <script src="js/bootstrap.js"></script>
  124.  
  125. </body>
  126. </html>
Add Comment
Please, Sign In to add comment