Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page
- import="java.util.*, bloggen.domain.*, bloggen.io.*, dk.au.hum.imv.persistence.db.JDBCConnectionFactory, bloggen.io.UserDAO, bloggen.domain.User"%>
- <%@ include file="Header.jsp"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
- <title>Music</title>
- <link rel="stylesheet" href="stylesheet.css" />
- </head>
- <body>
- <%
- String commentBody = request.getParameter("commentBody");
- String submitKnap = request.getParameter("submit-knap");
- if(request.getParameter("submit-knap") != null) {
- long currentUser = model.getUserId();
- JDBCConnectionFactory.initManualConnectionHandling("jdbc:mysql://student.hum.au.dk:3306/u201507985",
- "u201507985", "Butm51uR", "com.mysql.jdbc.Driver");
- String postId = request.getParameter("submit-knap");
- int convertIdToInt = Integer.parseInt(postId);
- CommentDAO.saveComment(model.getUserName(), commentBody, convertIdToInt);
- String redirectUrl = "/Aflevering_13/Index.jsp";
- response.sendRedirect(redirectUrl);
- }
- %>
- <div class = "containerWEB">
- <form action="Index.jsp" method="post">
- <div id="form" action="Index.jsp" method="post">
- <div class="form-horizontal">
- <fieldset>
- <legend>Nyt blogindlæg</legend>
- <div class="form-group">
- <table>
- <tr>
- <label class="col-md-4 control-label">Genre</label>
- <td><select name="genre">
- <option value="Jazz">Jazz</option>
- <option value="Rock">Rock</option>
- <option value="Hiphop">Hiphop</option>
- <option value="Pop">Pop</option>
- <option value="Electronic">Electronic</option>
- </select></td>
- </tr>
- </table>
- </div>
- <div class="form-group">
- <label class="col-md-4 control-label" for="postTitle"> Title</label>
- <div class="col-md-4">
- <input type="text" name="postTitle" id="blogTitle"
- class="form-control input-md" />
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 control-label"> Text</label>
- <div class="col-md-4">
- <textarea id="text" class="form-control" name="postText" rows="4"
- cols="50"></textarea>
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 control-label" for="submit">Submit</label>
- <div class="col-md-4">
- <input id="submit" type="submit" value="submit" name="submit"
- class="btn btn-success">
- </div>
- </div>
- </fieldset>
- </div>
- </div>
- </form>
- </div>
- <%
- String genre = request.getParameter("genre");
- String title = request.getParameter("postTitle");
- String text = request.getParameter("postText");
- long id = model.getUserId();
- User user = UserDAO.getUserById(id);
- if (request.getParameter("submit") != null) {
- PostDao.Post(title, user.getUserName(), text, genre);
- }
- %>
- <%
- ArrayList<Post> newPosts = PostDao.getAllPosts();
- %>
- <%
- for (Post posts : newPosts) {
- %>
- <div class="page">
- <h3><%=posts.getTitle()%></h3>
- <div class="details">
- <ul>
- <li><%=posts.getAuthor()%></li>
- <li><%=posts.getDate()%></li>
- <li><%=posts.getGenre()%></li>
- </ul>
- <div class="content">
- <p><%=posts.getText()%></p>
- </div>
- <div class = "commentBox">
- <fieldset>
- <form
- action="Index.jsp" method="post">
- <textarea id="commentBody" name ="commentBody" placeholder = "Text"> </textarea>
- <button name ="submit-knap"> Send </button>
- </form>
- </fieldset>
- </div>
- <hr>
- </div>
- </div>
- <%
- ArrayList<Comment> newComments = CommentDAO.getCommentsForPostId(posts.getPost_id());
- for (Comment comments : newComments) {
- %>
- <h5>Comment Title <%=comments.getUsername() %> </h5>
- <p> Text <%=comments.getText() %>
- <p> <%=comments.getDate() %>
- <%
- }
- %>
- <%
- }
- %>
- <script type="text/javascript">
- function resettoggle() {
- var e = document.getElementById('form');
- e.style.display = 'none';
- }
- function toggle_visibility(id) {
- var e = document.getElementById(id);
- if (e.style.display == 'none')
- e.style.display = 'block';
- else
- e.style.display = 'none';
- }
- </script>
- <%@ include file="Footer.jsp"%>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement