Advertisement
Guest User

CommentTESTBackUp

a guest
May 23rd, 2016
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. <script>
  2. $(document).ready(function() {
  3.  
  4. });
  5. $("form").submit(function(){
  6. alert("Data bliver indsat, når der trykkes ok");
  7. });
  8. </script>
  9.  
  10.  
  11.  
  12. <%
  13.  
  14. SessionModel model = (SessionModel)request.getSession().getAttribute("sessionModel");
  15. if (!model.isLoggedIn()) {
  16. response.sendRedirect("login.jsp"); //send bruger til login
  17. return; //afslut afvikling af resten af siden
  18. }
  19.  
  20. CommentDAO.getAllComments();
  21.  
  22. Comment testComment = new Comment("testen", "dette er en kommentar");
  23.  
  24.  
  25. System.out.println(testComment.title);
  26.  
  27.  
  28.  
  29. %>
  30.  
  31.  
  32. <div class="container">
  33. <h3>Student Database</h3>
  34. <table class="table table-striped">
  35. <tr><th>Titel</th><th>Krop</th></tr>
  36.  
  37. <%
  38. JDBCConnectionFactory.initManualConnectionHandling("jdbc:mysql://student.hum.au.dk:3306/infprojekt",
  39. "infprojekt", "1daKEoig", "com.mysql.jdbc.Driver");
  40. ArrayList<Comment> comments = CommentDAO.getAllComments();
  41. %>
  42.  
  43. <%
  44. for (Comment comment : comments) {
  45. %>
  46. <tr>
  47. <td><%=comment.getCommentTitle() %></td>
  48. <td><%=comment.getCommentBody() %></td>
  49. </tr>
  50. <%
  51. }
  52. %>
  53. </table>
  54. </div>
  55.  
  56. <%
  57.  
  58.  
  59. String title = request.getParameter("title");
  60. String body = request.getParameter("body");
  61.  
  62.  
  63. String createButton = request.getParameter("submit");
  64. if (createButton != null) {
  65.  
  66. long currentUser = model.getUserId();
  67. JDBCConnectionFactory.initManualConnectionHandling("jdbc:mysql://student.hum.au.dk:3306/infprojekt",
  68. "infprojekt", "1daKEoig", "com.mysql.jdbc.Driver");
  69. Comment myComment = new Comment(title, body);
  70. CommentDAO.setComment(myComment);
  71. String redirectURL = "/Studentsprojekt/CommentTest.jsp";
  72. response.sendRedirect(redirectURL);
  73. }
  74.  
  75. %>
  76.  
  77.  
  78.  
  79.  
  80. <form action="CommentTest.jsp" method="post" class="form-horizontal">
  81. <fieldset>
  82. <!-- Text input-->
  83. <div class="form-group">
  84. <div class="col-md-4" style="width:100%;">
  85. <input id="title" name="title" type="text" placeholder="Titel" class="form-control input-md">
  86.  
  87. </div>
  88. </div>
  89. <!-- Text input-->
  90. <div class="form-group">
  91. <div class="col-md-8" style="width:100%;">
  92. <input id="body" name="body" type="text" placeholder="Kommentar" class="form-control input-md">
  93. </div>
  94. </div>
  95.  
  96. <!-- Button -->
  97. <div class="form-group">
  98. <div class="col-md-4">
  99. <button id="submit" name="submit" class="btn btn-default" class="form-control input-md">Send</button>
  100. </div>
  101. </div>
  102.  
  103. </fieldset>
  104. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement