如何在一个jsp页面中使用多个表

时间:2014-10-24 14:32:53

标签: jsp jdbc

我必须在一个jsp页面中使用两个表...一个表正在从数据库中检索数据,另一个表正在将数据插入到第二个表中。 请给出任何解决方案..它不起作用。在第一页有一个搜索按钮,它带你到下一页,即searchbid.jsp

第1页

try.jsp

<div class="form">
            <form method="post" action="http://localhost:8080/OA/searchbid.jsp.jsp">
               <input type="text" name="t1" placeholder="Search..">  <input type="submit" name="b1" value="Search" style="font-family: Pristina;
                                                                                       padding: 1px 12px;                                                                                           font-size: 17px;                                                                                           background-color: inherit;                                                                                           color: aliceblue;                                                                                          ">
            </form>    
        </div>   

第二页 - searchbid.jsp

<%@ page import="java.sql.*;" %>
<%
try{
    HttpSession ss1=request.getSession();
                String ss3=(String)ss1.getAttribute("ss2");
    out.print("yes");
    String s1=request.getParameter("b1");
    if(s1.equals("Search")){
    String item=request.getParameter("t1");
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:oa");
    Statement smt=con.createStatement();
    ResultSet rs=smt.executeQuery("select * from auction where iname='"+item+"'");
    while(rs.next()){
    String name=rs.getString("iname");
    String desc=rs.getString("description");
    String mp=rs.getString("m_p");
    String ae=rs.getString("A_e");``

   out.print("no");
     out.print("<br><img src='"+rs.getString("path")+"' width='200' height='200'>");
   out.print("<br>Name<br>");
  out.print("<input type='text' name='n1' value='"+name+"'>");

    %>
      Your Bid <input type="text" name="t2">
           <br><input type="submit" name="b2" value="Click">
<%

         String ap=request.getParameter("b2");
                          if (ap.equals("Click")) {
                                String ybid = request.getParameter("t2");

                                    smt.executeUpdate("insert into ebid(uid,pname,yourb)values('"+ss3+"','"+name+"',"+ybid+")");
                                    out.print("Thanks for Bidding");   }}}   
    catch(Exception t)
{
}    }
    }

       catch(Exception m)
{
}  
 %>
</form>     

0 个答案:

没有答案