Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page import="dk.au.hum.imv.persistence.db.JDBCConnectionFactory,
- java.util.*, DAO.*, java.sql.*, java.lang.String, java.lang.*, java.util.Date, domain.*"%>
- <jsp:include page="header.jsp" />
- <%
- 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
- }
- Student student = StudentDAO.getStudentById(model.getUserId());
- String studentName = student.getName();
- PostDAO postDao = new PostDAO();
- %>
- <title>Studerende</title>
- <%
- String title = request.getParameter("title");
- String body = request.getParameter("body");
- String cat = request.getParameter("cat");
- 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");
- Post mitpost = new Post(title, body, cat, currentUser);
- PostDAO.setPost(mitpost);
- String redirectURL = "/Studentsprojekt/forum.jsp";
- response.sendRedirect(redirectURL);
- }
- String commentTitle = request.getParameter("commentTitle");
- String commentBody = request.getParameter("commentBody");
- if(request.getParameter("submit-knap") != null) {
- long currentUser = model.getUserId();
- String postId = request.getParameter("submit-knap");
- int convertIdToInt = Integer.parseInt(postId);
- JDBCConnectionFactory.initManualConnectionHandling("jdbc:mysql://student.hum.au.dk:3306/infprojekt",
- "infprojekt", "1daKEoig", "com.mysql.jdbc.Driver");
- Comment mincomment = new Comment(commentTitle, commentBody, convertIdToInt, currentUser);
- CommentDAO.setComment(mincomment);
- String redirectURL = "/Studentsprojekt/forum.jsp";
- response.sendRedirect(redirectURL);
- }
- %>
- <%
- JDBCConnectionFactory.initManualConnectionHandling("jdbc:mysql://student.hum.au.dk:3306/infprojekt",
- "infprojekt", "1daKEoig", "com.mysql.jdbc.Driver");
- ArrayList<Post> postBeer = PostDAO.getPostByCat("Øl");
- ArrayList<Post> postReading = PostDAO.getPostByCat("Læsning");
- %>
- <div class="container">
- <div class="blog-header">
- <h1 class="blog-title">Forum</h1>
- <p class="lead blog-description">Herunder kommer to forummer hhv. læsning og øl</p>
- <hr>
- </div>
- <div class="row">
- <div class="col-sm-8 blog-main">
- <div class="blog-header">
- <h2 class="blog-title"><strong>Øl</strong></h2>
- <p class="lead blog-description">Herunder kommer posts i kategorien Øl</p>
- <hr>
- </div>
- <div class="blog-post">
- <%
- for (Post posts : postBeer) {
- %>
- <h3 class="blog-post-title">Post titel: <%=posts.getPostTitle() %></h3>
- <p class="blog-post-meta" id="cat">Kategori: <%=posts.getPostCat() %></p>
- <p class="blog-post-meta" id="date">Dato: <strong><%=posts.convertDate() %></strong></p>
- <p>Oprettet af: <%= postDao.getPostAuthor(posts.getStudentId()) %></p>
- <p id="beskrivelse">Beskrivelse: <%=posts.getPostBody() %></p>
- <FORM action="forum.jsp" NAME="form1" METHOD="POST">
- <!-- Text input-->
- <div class="form-group">
- <div class="col-md-4" style="width:100%;">
- <input id="commentTitle" name="commentTitle" type="text" placeholder="Post titlen" class="form-control input-md">
- </div>
- </div>
- <!-- Description input -->
- <div class="form-group">
- <div class="col-md-4" style="width:100%;">
- <textarea class="form-control" id="commentBody" name="commentBody" placeholder="Skriv dit post indhold her:"></textarea>
- </div>
- </div>
- <button name="submit-knap" class="btn btn-default" value="<%=posts.getPostId() %>" class="form-control input-md" id="<%=posts.getPostId() %>">Send</button>
- </FORM>
- <hr>
- <%
- }
- %>
- </div>
- <!-- /.blog-post -->
- <div class="blog-header">
- <h2 class="blog-title"><strong>Læsning</strong></h2>
- <p class="lead blog-description">Herunder kommer posts i kategorien læsning</p>
- <hr>
- </div>
- <div class="blog-post">
- <%
- for (Post posts : postReading) {
- %>
- <h3 class="blog-post-title">Post titel: <%=posts.getPostTitle() %></h3>
- <p class="blog-post-meta" id="cat">Kategori: <%=posts.getPostCat() %></p>
- <p class="blog-post-meta" id="date">Dato: <strong><%=posts.convertDate() %></strong></p>
- <p>Oprettet af: <%= postDao.getPostAuthor(posts.getStudentId()) %></p>
- <p id="beskrivelse">Beskrivelse: <%=posts.getPostBody() %></p>
- <hr>
- <%
- }
- %>
- </div>
- <!-- /.blog-post -->
- </div>
- <div class="col-sm-3 col-sm-offset-1 blog-sidebar">
- <div class="sidebar-module sidebar-module-inset">
- <h4>Opret en post:</h4>
- <form action="forum.jsp" method="post" class="form-horizontal">
- <fieldset>
- <div class="form-group">
- <div class="col-md-4" style="width:100%;">
- <input id="title" name="title" type="text" placeholder="Post titlen" class="form-control input-md">
- </div>
- </div>
- <div class="form-group">
- <div class="col-md-4" style="width:100%;">
- <textarea class="form-control" id="body" name="body" placeholder="Skriv dit post indhold her:"></textarea>
- </div>
- </div>
- <div class="form-group ">
- <div class="col-md-4" style="width:100%;">
- <select class="select form-control" id="cat" name="cat">
- <option value="Øl">
- Øl
- </option>
- <option value="Læsning">
- Læsning
- </option>
- </select>
- </div>
- </div>
- <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>
- </div>
- <div class="sidebar-module">
- <h4>Archives</h4>
- <ol class="list-unstyled">
- <li><a href="#">March 2014</a></li>
- <li><a href="#">February 2014</a></li>
- <li><a href="#">January 2014</a></li>
- <li><a href="#">December 2013</a></li>
- <li><a href="#">November 2013</a></li>
- <li><a href="#">October 2013</a></li>
- <li><a href="#">September 2013</a></li>
- <li><a href="#">August 2013</a></li>
- <li><a href="#">July 2013</a></li>
- <li><a href="#">June 2013</a></li>
- <li><a href="#">May 2013</a></li>
- <li><a href="#">April 2013</a></li>
- </ol>
- </div>
- <div class="sidebar-module">
- <h4>Elsewhere</h4>
- <ol class="list-unstyled">
- <li><a href="#">GitHub</a></li>
- <li><a href="#">Twitter</a></li>
- <li><a href="#">Facebook</a></li>
- </ol>
- </div>
- </div><!-- /.blog-sidebar -->
- </div>
- </div>
- <script>
- /*
- $(document).ready(function () {
- $(".submit").click(function() {
- alert($(this).attr("id"))
- })
- })
- */
- </script>
- <jsp:include page="footer.jsp" />
- </body>
- </html>
Add Comment
Please, Sign In to add comment