Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%
- String opleiding1 = "";
- if(request.getParameter("Opleiding1") != null) {
- opleiding1 = request.getParameter("Opleiding1");
- }
- %>
- <form action = "verkoper.jsp" method="GET">
- <input name="Opleiding1" type="text" id="Opeleiding1" value="<%=opleiding1%>">
- <input type ="submit" value="Zoeken">
- </form> <br>
- <%
- Connection connect = null;
- Statement s = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- connect = DriverManager.getConnection("jdbc:mysql://localhost:3307/boekendb","root", "usbw");
- s = connect.createStatement();
- String sql = "SELECT * FROM tbl_boeken WHERE opleiding like '%" + opleiding1 + "%' or titel like '%" + opleiding1 + "%' or auteur like '%" + opleiding1 + "%'" ;
- System.out.println(sql);
- ResultSet rec = s.executeQuery(sql);
- %>
- <from action="./VerkoopServlet" method="POST">
- <table width="600" border="1">
- <tr>
- <th width="91"> <div align="center">BoekID </div></th>
- <th width="98"> <div align="center">Auteur </div></th>
- <th width="198"> <div align="center">ISBN</div></th>
- <th width="97"> <div align="center">Opleiding</div></th>
- <th width="59"> <div align="center">Prijs</div></th>
- <th width="71"> <div align="center">Titel</div></th>
- <th width="71"> <div align="center">Verkopen</div></th>
- <th width="71"> <div align="center">Verkoper</div></th>
- </tr>
- <%while((rec!=null) && (rec.next()) ) { %>
- <tr>
- <td id="importRow" name="boekId"><div align="center"><%=rec.getString("boekId")%></div></td>
- <td id="importRow" name="auteur"><%=rec.getString("auteur")%></td>
- <td id="importRow" name="isbn"><%=rec.getString("isbn")%></td>
- <td id="importRow" name="opleiding"><div align="center"><%=rec.getString("opleiding")%></div></td>
- <td id="importRow" name="prijs" align="right"><%=rec.getString("prijs")%></td>
- <td id="importRow" name="titel" align="right"><%=rec.getString("titel")%></td>
- <span id="importRow">${rec.getBoekId().get(i)}</span>
- <td><input type="radio" name="importRow" value="${rec.getString("boekId").get(i)}"></td>
- <td><%=session.getAttribute("userid")%></td>
- </tr>
- <%}%>
- </table>
- <input type="submit" name="reserveButton" value="Winkelmand" ></input>
- <button type="button" name="backtosearchButton">Back to Search</button>
- </from>
- <script>
- $('#thetable').find('tr').click( function(){
- alert('You clicked row '+ ($(this).index()+1) );
- });
- </script>
- <%
- } catch (Exception e) {
- // TODO Auto-generated catch block
- out.println(e.getMessage());
- e.printStackTrace();
- }
- try {
- if(s!=null){
- s.close();
- connect.close();
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- out.println(e.getMessage());
- e.printStackTrace();
- }
- %>
- </body>
- protected void processRequest(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- String getKolom = request.getParameter("importRow");
- List list = Arrays.asList(getKolom);
- String action = request.getParameter("action");
- int boekId = 0;
- if(getKolom != null && getKolom.length() > 0){
- boekId =Integer.parseInt(getKolom);}
- Tbl_boekenverkoop verkoop1 = new Tbl_boekenverkoop(boekId);
- Tbl_boekenverkoop verkoop2 = new Tbl_boekenverkoop();
- if("reserveButton".equalsIgnoreCase(action)){
- bd.toevoegenVerkopen(verkoop1);}
- ArrayList<Tbl_boeken> boek1 = new ArrayList<Tbl_boeken>();
- request.getSession().setAttribute("getKolom", verkoop1);
- RequestDispatcher dispatcher = request.getRequestDispatcher("/verkoper.jsp");
- dispatcher.forward(request, response);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement