单击“应用”按钮后,将相应的值保存到jsp页面中的数据库中

|| 我正在使用jsp在来自Sql Server数据库的页面中打印当前空缺。 我的代码是:
<form method=\"post\" action=\"\">  
    <table align=\"left\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">
    <tr><td><input id=\"email\" size=\"20\" type =\"hidden\" value = \"<%= session.getAttribute( \"name\" ) %>\" name=\"email\" /></td></tr>
<%@ page import=\"java.util.*\" %>
<%@ page import=\"javax.sql.*;\" %>

<% 
    java.sql.Connection con;
    java.sql.Statement s;
    java.sql.ResultSet rs;
    java.sql.PreparedStatement pst;

    con=null;
    s=null;
    pst=null;
    rs=null;

    try
    {
                con=DriverManager.getConnection(\"jdbc:jtds:sqlserver://W2K8SERVER:1433/career\",\"user name\",\"password\" );

    }
    catch(ClassNotFoundException e)
    {
        e.printStackTrace();
    }
    String sql = \"select * from currentopening\";
    try
    {
    s = con.createStatement();
    rs = s.executeQuery(sql);
    %>





  <tr>
       <td width=\"150\" align=\"center\"><b>Job Code</b> </td> 
       <td width=\"600\" align=\"center\"><b>Discription</b> </td>
        <td width=\"600\" align=\"center\"><b>Position</b> </td>
   </tr>

    <%
    int no=1;
   while( rs.next() )
   {

   %>



   <tr>
    <td width=\"150\" align=\"center\"><input id=\"jobid\" size = \"2\" type =\"text\" value = \"<%= rs.getString(\"job_code\") %>\" name=\"jobid\" /><%= rs.getString(\"job_code\") %></td>

    <td width=\"400\" align=\"justify\"><input id=\"pos1\" type =\"hidden\" size = \"2\" value = \"<%= rs.getString(\"position\") %>\" name=\"pos\" /><%= rs.getString(\"discription\") %></td>
    <!--  
    <td width=\"400\" align=\"center\"><textarea name=\"dis\" cols=\"40\" rows=\"4\" ><%= rs.getString(\"discription\") %></textarea></td>

    -->
       <td width=\"400\" align=\"center\"><input id=\"pos\" type =\"text\" size = \"2\" value = \"<%= rs.getString(\"position\") %>\" name=\"pos\" /><%= rs.getString(\"position\") %></td>
    <td width=\"100\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Apply\"/></td>
    <td> </td>
   </tr>

   <%
   no++;
}
%>

<%

}
    catch(Exception e)
    {
        response.getWriter().println(e.getMessage());   
    }

    finally
    {
        if(rs!=null) rs.close();
        if(s!=null) s.close();
        if(con!=null) con.close();
        }

        %>


 </table>
</form>
现在,我想分别单击“应用”按钮将相应的开口保存到表中。 就像我想将作业代码和职位保存到数据库中一样。 我该如何实现?     
已邀请:
        使用servlet处理从JSP提交的数据,并将数据从中保存到数据库中。 有许多执行此操作的代码示例:这里是其中之一 http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html     

要回复问题请先登录注册