Advertisement
hyunjeong

Untitled

Aug 29th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@ page import = "java.io.PrintWriter" %>
  3. <%@ page import = "bbs.Bbs" %>
  4. <%@ page import = "bbs.BbsDAO" %>
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  8. <title>JSP 게시판 웹사이트</title>
  9. <link rel="stylesheet" href="css/bootstrap.css">
  10. </head>
  11. <body>
  12. <%
  13. String userId = null;
  14. if(session.getAttribute("userId") != null ) {
  15. userId = (String) session.getAttribute("userId");
  16. }
  17. if (userId== null) {
  18. PrintWriter script = response.getWriter();
  19. script.println("<script>");
  20. script.println("alert('로그인을 하세요.')");
  21. script.println("location.href= 'login.jsp' ");
  22. script.println("</script>");
  23. }
  24. int bbsId = 0;
  25. System.out.println(request.getParameter("bbsId"));
  26. if(request.getParameter("bbsId") != null ) {
  27. bbsId= Integer.parseInt(request.getParameter("bbsId"));
  28. }
  29. if(bbsId==0) {
  30. PrintWriter script = response.getWriter();
  31. script.println("<script>");
  32. script.println("alert('유효하지 않은 글입니다.')");
  33. script.println("location.href= 'bbs.jsp' ");
  34. script.println("</script>");
  35. }
  36. Bbs bbs = new BbsDAO().getBbs(bbsId);
  37. if(!userId.equals(bbs.getUserId())){
  38. PrintWriter script = response.getWriter();
  39. script.println("<script>");
  40. script.println("alert('권한이 없습니다.')");
  41. script.println("location.href= 'bbs.jsp' ");
  42. script.println("</script>");
  43. }
  44. %>
  45. <nav class= "navbar navbar-default">
  46. <div class="navbar-header">
  47. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  48. <span class="icon-bar"></span>
  49. <span class="icon-bar"></span>
  50. <span class="icon-bar"></span>
  51. </button>
  52. <a class="navbar-brand" href="login.jsp">JSP게시판 웹 사이트</a>
  53. </div>
  54. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  55. <ul class="nav navbar-nav">
  56. <li><a href="main.jsp">메인</a></li>
  57. <li class="active"><a href="bbs.jsp">게시판</a></li>
  58. </ul>
  59. <ul class="nav navbar-nav navbar-right">
  60. <li class="dropdown">
  61. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
  62. aria-haspopup="true" aria-expanded="false" >
  63. 회원관리<span class=caret></span>
  64. </a>
  65. <ul class="dropdown-menu">
  66.  
  67. <li><a href="logoutAction.jsp">로그아웃</a></li>
  68. </ul>
  69. </li>
  70. </ul>
  71. </div>
  72. </nav>
  73. <div class="container">
  74. <div class="row">
  75. <form method="post" action="updateAction.jsp?bbsId=<%=bbsId%>">
  76. <table class="table table-striped" style="text-align:center; border:1px solid #dddddd">
  77. <thead>
  78. <tr>
  79. <th colspan="2" style="background-color: #eeeeee; text-align:center;">게시판 글 수정</th>
  80. </tr>
  81. </thead>
  82. <tbody>
  83. <tr>
  84. <td><input type="text" class="form-control" placeholder="글 제목" name="bbsTitle" maxlength="50" value="<%= bbs.getBbsTitle()%>"></td>
  85. </tr>
  86. <tr>
  87. <td><textarea class="form-control" placeholder="글 내용" name="bbsContent"
  88. maxlength="2048" style="height:350px;"><%= bbs.getBbsContent()%></textarea></td>
  89. </tr>
  90. </tbody>
  91.  
  92. </table>
  93. <input type="submit" class="btn btn-primary pull-right" value="글수정">
  94. </form>
  95. </div>
  96. </div>
  97. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  98. <script src="js/bootstrap.js"></script>
  99. </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement