Advertisement
Guest User

Untitled

a guest
Jan 28th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. <%
  2. String opleiding1 = "";
  3. if(request.getParameter("Opleiding1") != null) {
  4. opleiding1 = request.getParameter("Opleiding1");
  5. }
  6.  
  7.  
  8. %>
  9.  
  10. <form action = "verkoper.jsp" method="GET">
  11. <input name="Opleiding1" type="text" id="Opeleiding1" value="<%=opleiding1%>">
  12. <input type ="submit" value="Zoeken">
  13.  
  14.  
  15. </form> <br>
  16.  
  17.  
  18. <%
  19. Connection connect = null;
  20. Statement s = null;
  21.  
  22. try {
  23. Class.forName("com.mysql.jdbc.Driver");
  24.  
  25. connect = DriverManager.getConnection("jdbc:mysql://localhost:3307/boekendb","root", "usbw");
  26.  
  27. s = connect.createStatement();
  28.  
  29. String sql = "SELECT * FROM tbl_boeken WHERE opleiding like '%" + opleiding1 + "%' or titel like '%" + opleiding1 + "%' or auteur like '%" + opleiding1 + "%'" ;
  30.  
  31. System.out.println(sql);
  32.  
  33. ResultSet rec = s.executeQuery(sql);
  34. %>
  35. <from action="./VerkoopServlet" method="POST">
  36. <table width="600" border="1">
  37. <tr>
  38. <th width="91"> <div align="center">BoekID </div></th>
  39. <th width="98"> <div align="center">Auteur </div></th>
  40. <th width="198"> <div align="center">ISBN</div></th>
  41. <th width="97"> <div align="center">Opleiding</div></th>
  42. <th width="59"> <div align="center">Prijs</div></th>
  43. <th width="71"> <div align="center">Titel</div></th>
  44. <th width="71"> <div align="center">Verkopen</div></th>
  45. <th width="71"> <div align="center">Verkoper</div></th>
  46. </tr>
  47.  
  48. <%while((rec!=null) && (rec.next()) ) { %>
  49.  
  50.  
  51. <tr>
  52. <td id="importRow" name="boekId"><div align="center"><%=rec.getString("boekId")%></div></td>
  53. <td id="importRow" name="auteur"><%=rec.getString("auteur")%></td>
  54. <td id="importRow" name="isbn"><%=rec.getString("isbn")%></td>
  55. <td id="importRow" name="opleiding"><div align="center"><%=rec.getString("opleiding")%></div></td>
  56. <td id="importRow" name="prijs" align="right"><%=rec.getString("prijs")%></td>
  57. <td id="importRow" name="titel" align="right"><%=rec.getString("titel")%></td>
  58.  
  59.  
  60. <span id="importRow">${rec.getBoekId().get(i)}</span>
  61. <td><input type="radio" name="importRow" value="${rec.getString("boekId").get(i)}"></td>
  62.  
  63.  
  64.  
  65. <td><%=session.getAttribute("userid")%></td>
  66.  
  67. </tr>
  68. <%}%>
  69. </table>
  70.  
  71. <input type="submit" name="reserveButton" value="Winkelmand" ></input>
  72. <button type="button" name="backtosearchButton">Back to Search</button>
  73.  
  74. </from>
  75. <script>
  76. $('#thetable').find('tr').click( function(){
  77. alert('You clicked row '+ ($(this).index()+1) );
  78. });
  79. </script>
  80. <%
  81. } catch (Exception e) {
  82. // TODO Auto-generated catch block
  83. out.println(e.getMessage());
  84. e.printStackTrace();
  85. }
  86.  
  87. try {
  88. if(s!=null){
  89. s.close();
  90. connect.close();
  91. }
  92. } catch (SQLException e) {
  93. // TODO Auto-generated catch block
  94. out.println(e.getMessage());
  95. e.printStackTrace();
  96. }
  97. %>
  98. </body>
  99.  
  100. protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  101. throws ServletException, IOException {
  102. String getKolom = request.getParameter("importRow");
  103. List list = Arrays.asList(getKolom);
  104.  
  105. String action = request.getParameter("action");
  106. int boekId = 0;
  107. if(getKolom != null && getKolom.length() > 0){
  108. boekId =Integer.parseInt(getKolom);}
  109. Tbl_boekenverkoop verkoop1 = new Tbl_boekenverkoop(boekId);
  110. Tbl_boekenverkoop verkoop2 = new Tbl_boekenverkoop();
  111. if("reserveButton".equalsIgnoreCase(action)){
  112. bd.toevoegenVerkopen(verkoop1);}
  113. ArrayList<Tbl_boeken> boek1 = new ArrayList<Tbl_boeken>();
  114. request.getSession().setAttribute("getKolom", verkoop1);
  115. RequestDispatcher dispatcher = request.getRequestDispatcher("/verkoper.jsp");
  116. dispatcher.forward(request, response);
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement