Relating radio buttons with table rows
[nobr]Hi,
I have a program which displays a table. I am using rs.next() to display the resultset of the query. I would like to associate radio buttons to each of the row while displaying. So that when the user selects the radio button and clicks on a button "Delete" at the bottom, the whole row should be deleted. Could any one tell me how to associate radio buttons with each of the rows and how can i know which radio button has been selected and the the whole row information associated with that row. Any help would be greatly appreciated.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
publicclass tableextends HttpServlet
{
publicvoid init(ServletConfig config)throws ServletException
{
super.init(config);
System.out.println("**** Inside Table Servlet ***");
System.out.flush();
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");}
catch (ClassNotFoundException e)
{
System.out.println("Couldn't load Oracle driver"); System.out.flush();
thrownew UnavailableException(this,"Couldn't load Oracledriver");
}
catch (Exception e)
{
System.out.println("\nTable Servlet Exception: "+ e +" ***\n");
e.printStackTrace();
}
System.out.println("***Leaving Table servlet init ***");
}
publicvoid doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException,
IOException{
System.out.println("**** Inside table Servlet - doGet ****");
doPost(req, res);
}
publicvoid doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException,
IOException
{
response.setContentType("Text/html");
PrintWriter out = response.getWriter(); out.println("<HTML>"); out.println("<HEAD><TITLE>Holiday
Table</TITLE></HEAD>"); out.println("<BODY BGCOLOR=\"#FFFFFF\">"); out.println("<CENTER>");
out.println("<BR><BR>");
Connection conn =null;
try
{
conn = DriverManager.getConnection("jdbc racle:thin:@asdf:1521:dsf","xyz","xyz");
Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("Select * from hlday10t");
//Print start of table and column headers out.println("<TABLE CELLSAPCING=\"0\" CELLPADDING=\"3\"
BORDER=\"1\">"); out.println("<TR><TH>HOLIDAY_CODE</TH><TH>HOLIDAY_DESCR</TH>");
out.println("<TH>HOLIDAY_DATE</TH><TH>LAST_CHANGE_USERID</TH>");
out.println("<TH>LAST_CHANGE_TMSTMP</TH></TR>");
//Loop through results of the query while(rs.next())
{
out.println("<TR>");
out.println("<TD>" + rs.getString("HOLIDAY_CODE") +"</TD>");
out.println("<TD>" + rs.getString("HOLIDAY_DESCR") +"</TD>");
out.println("<TD>" + rs.getString("HOLIDAY_DATE") +"</TD>");
out.println("<TD>"+ rs.getString("LAST_CHANGE_USERID") +"</TD>");
out.println("<TD>" + rs.getString("LAST_CHANGE_TMSTMP") +"</TD>");
out.println("</TR>");
}
out.println("</TABLE>");
}
catch(SQLException e)
{
out.println("SQLException: " + e.getMessage() +"<BR>");
e.printStackTrace();
while((e = e.getNextException()) !=null) out.println(e.getMessage() +"<BR>");
}
finally
{
//Clean up resources, close the connection if(conn != null)
{
try
{
conn.close();
}
catch (Exception ignored){}
}
}
out.println("<TR>");
out.println("<TD><Form method=\"post\" action=\"Add\">"); out.println("<INPUT type=\"submit\"
value=\"Add\">"); out.println("<INPUT type=\"hidden\" name=\"action\" value=\"Add\">");
out.println("</Form></TD>");
out.println("<TD><Form method=\"post\" action=\"Modify\">");
out.println("<INPUT type=\"submit\" value=\"Modify\">");
out.println("<INPUT type=\"hidden\" name=\"action\" value=\"Modify\">");
out.println("</Form></TD>"); out.println("<TD><Form method=\"post\" action=\"Delete\">");
out.println("<INPUT type=\"submit\" value=\"Delete\">"); out.println("<INPUT type=\"hidden\"
name=\"action\" value=\"Delete\">"); out.println("</Form></TD>");
out.println("</TR>");
out.println("</CENTER>");
out.println("</BODY>");
out.println("</HTML>");
}
}
[/nobr]

