这是表,现在我想将sno列的值发送到另一个jsp 页面。
我已经创建了按钮形式的超链接,我想在单击按钮时发送值。
<table id="table" border="5" cellspacing="2" cellpadding="15">
<thead>
<tr>
<th>S.No</th>
<th>Company Name</th>
<th>Created By</th>
<th>Company Address</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/assignment","root","root");
Statement st = con.createStatement();
ResultSet rs=st.executeQuery("select * from company");
int count=0;
while(rs.next())
{
out.println("<tr>");
out.println("<td>"+rs.getString("sno")+"</td>");
out.println("<td>"+rs.getString("company_name")+"</td>");
out.println("<td>"+rs.getString("userid")+"</td>");
out.println("<td>"+rs.getString("company_address")+"</td>");
String a=rs.getString("status");
if(a.equals("Unapproved"))
{
out.print("<td><a href='edit.jsp'><input type='submit' value='Edit'></a>   <a href='delete.jsp'><input type='submit' value='delete'></a>   <a href='approve.jsp'><input type='submit' value='Approve'></a></td>");
}
else
{
out.print("<td><a href='edit.jsp'><input type='submit' value='Edit'></a>   <a href='delete.jsp'><input type='submit' value='delete'></a></td>");
}
out.println("</tr>");
count=1;
}
if(count==0)
{
out.println("NO RECORD'S FOUND");
}
%>
</tbody>
</table>
答案 0 :(得分:0)
例如,您可以将ResultSet放入Session中,然后在另一个JSP中读取它。
保存到会话:
session.setAttribute("resultset", rs);
从会话中读取:
ResultSet rs = (ResultSet) session.getAttribute("resultset");
答案 1 :(得分:0)
您可以在链接本身中附加sno
作为查询字符串:
String sno = rs.getString("sno");
out.println("<td>"+sno+"</td>");
...
out.print("<td><a href='edit.jsp?sno="+sno+"'><input type='submit' value='Edit'></a>   <a href='delete.jsp?sno="+sno+"'><input type='submit' value='delete'></a>   <a href='approve.jsp?sno="+sno+"'><input type='submit' value='Approve'></a></td>");