Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(document).ready(function() {
- });
- $("form").submit(function(){
- alert("Data bliver indsat, når der trykkes ok");
- });
- </script>
- <%
- SessionModel model = (SessionModel)request.getSession().getAttribute("sessionModel");
- if (!model.isLoggedIn()) {
- response.sendRedirect("login.jsp"); //send bruger til login
- return; //afslut afvikling af resten af siden
- }
- CommentDAO.getAllComments();
- Comment testComment = new Comment("testen", "dette er en kommentar");
- System.out.println(testComment.title);
- %>
- <div class="container">
- <h3>Student Database</h3>
- <table class="table table-striped">
- <tr><th>Titel</th><th>Krop</th></tr>
- <%
- JDBCConnectionFactory.initManualConnectionHandling("jdbc:mysql://student.hum.au.dk:3306/infprojekt",
- "infprojekt", "1daKEoig", "com.mysql.jdbc.Driver");
- ArrayList<Comment> comments = CommentDAO.getAllComments();
- %>
- <%
- for (Comment comment : comments) {
- %>
- <tr>
- <td><%=comment.getCommentTitle() %></td>
- <td><%=comment.getCommentBody() %></td>
- </tr>
- <%
- }
- %>
- </table>
- </div>
- <%
- String title = request.getParameter("title");
- String body = request.getParameter("body");
- String createButton = request.getParameter("submit");
- if (createButton != null) {
- long currentUser = model.getUserId();
- JDBCConnectionFactory.initManualConnectionHandling("jdbc:mysql://student.hum.au.dk:3306/infprojekt",
- "infprojekt", "1daKEoig", "com.mysql.jdbc.Driver");
- Comment myComment = new Comment(title, body);
- CommentDAO.setComment(myComment);
- String redirectURL = "/Studentsprojekt/CommentTest.jsp";
- response.sendRedirect(redirectURL);
- }
- %>
- <form action="CommentTest.jsp" method="post" class="form-horizontal">
- <fieldset>
- <!-- Text input-->
- <div class="form-group">
- <div class="col-md-4" style="width:100%;">
- <input id="title" name="title" type="text" placeholder="Titel" class="form-control input-md">
- </div>
- </div>
- <!-- Text input-->
- <div class="form-group">
- <div class="col-md-8" style="width:100%;">
- <input id="body" name="body" type="text" placeholder="Kommentar" class="form-control input-md">
- </div>
- </div>
- <!-- Button -->
- <div class="form-group">
- <div class="col-md-4">
- <button id="submit" name="submit" class="btn btn-default" class="form-control input-md">Send</button>
- </div>
- </div>
- </fieldset>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement