在jsp

时间:2016-12-26 13:28:34

标签: java mysql jsp

我正在写一个在线预订系统应用程序。用户可以使用复选框选择活动。然后,他们可以提交他们的预订。我的复选框位置有问题,我不知道如何使用提交按钮提交这些已检查的预订。

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import ="java.sql.*" %>




<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>Book Ticket</title>
</head>
<body>
<center>    
<table border="1" width="30%" height="30%">
    <tr><th><font color='#D18603'>Activity ID.</font></th>
        <th><font color='#D18603'>Type</font></th>
        <th><font color='#D18603'>Description</font></th>
        <th><font color='#D18603'>City</font></th>
        <th><font color='#D18603'>Location</font></th>
        <th><font color='#D18603'>Date</font></th>
        <th><font color='#D18603'>Price</font></th>
        <th><font color='#D18603'>Buy</font></th>
    </tr>
    <td><b><font color='#663300'><input type="checkbox" name="ticket"       value=""/></font></td></b>



    <%
        Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
        Connection con =   DriverManager.getConnection("jdbc:derby://localhost:1527/users", "users", "123");

        Statement st = con.createStatement();
        ResultSet rs;
        rs = st.executeQuery("select * from activities");
        while (rs.next()) {

            String activityid1 = rs.getString("id");
            String type1 = rs.getString("type");
            String description1 = rs.getString("description");
            String city1 = rs.getString("city");
            String location1 = rs.getString("location");
            String date1 = rs.getString("date");
            String price1 = rs.getString("price");

            out.println("<tr>");
            out.println("<td>" + activityid1 + "</td>");
            out.println("<td>" + type1 + "</td>");
            out.println("<td>" + description1 + "</td>");
            out.println("<td>" + city1 + "</td>");
            out.println("<td>" + location1 + "</td>");
            out.println("<td>" + date1 + "</td>");
            out.println("<td>" + price1 + "</td>");

            out.println("</tr>");

        }


    %>

 </center>
 </table></body>
 <tr>
 <td colspan="10"><input type="submit" value="Submit" /></td>
 <td><input type="reset" value="Reset" /></td>
 </tr> 
 <br><br><a href='logout.jsp'>Log out</a>  
 </html>

1 个答案:

答案 0 :(得分:0)

请将复选框放入while循环中,复选框的值具有activityid1。用表格包围代码。创建java servlet或其他jsp。

pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    @Override
    public void onPageScrolled(int position, float positionOffset, 
                            int positionOffsetPixels) { }

    @Override
    public void onPageSelected(int position) {
        // set the second current page regarding the position of the first
        pagerpacks.setCurrentItem(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) { }
});

enter image description here

提交表单,您可以在另一个jsp中获取选中的值,例如 test.jsp 或TestServlet。

library(dplyr)


by_date <- group_by(df, DATE)

by_date <- summarise(by_date, frecuency = n())

最后,使用user_id

保存activityid

你可以看一下。 MVC in JSP

您也可以使用JSTL库。不建议在JSP页面中编写更多java代码。在Java类中连接数据库。

我希望它会有所帮助。