I wrote several
servlets in the first(main), I have:
insert
report
delete
When your choice is insert you insert employes data like, name, birthdate and SSN.
When your choice is report you will see the all employe data.
My problem is in the process_delete. I wrote the delete servlet I put input type = "checkbox" and input type = "submit" value="Delete".When I use del servlet and choice to delete some employe data I click the delete button and he submit the information to process_delete and here is the problem because I don't no how to put this in my code process_servlet.
My del servlet :
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletInputStream.*;
public class del extends HttpServlet
{
public void doGet (
HttpServletRequest request,
HttpServletResponse response
) throws ServletException, IOException
{
PrintWriter out;
response.setContentType("text/html");
out = response.getWriter();
try {
FileReader file1 = new FileReader("c:\\s_test\\data.txt");
BufferedReader buff = new BufferedReader(file1);
out.println("<HTML><BODY>");
out.println("<Page for delete"> );
out.println("<table border=\"1\" width=\"100%\">");
out.println("<Form action=\"http://localhost/servlets/process_del\"method=GET>");
out.println("<tr>");
out.println("<td width=\"25%\">NAME</td>");
out.println("<td width=\"25%\">SSN</td>");
out.println("<td width=\"25%\">BIRTHDATE</td></tr>");
out.println("<td><input type=\"reset\" Value=\"Cancel\" name=\"B2\"></tr>");
out.println("<td><input type=\"submit\" Value=\"Delete\" name=\"B2\"></tr>");
String data_line = new String(buff.readLine());
while ((data_line = buff.readLine()) != null) {
String name1 = data_line.substring(0,20).trim();
String SSN1 = data_line.substring(20,30).trim();
String birthdate1= data_line.substring(30).trim();
out.println("<tr>");
out.println("<td width=\"25%\"><input type=\"checkbox\" name=\"C1\" value=\"on\"></td>");
out.println("<td>"+ name1 + "<td>" + SSN1 + "<td>" + birthdate1 + "</td></td></td></tr>");
}
out.println("</table>");
out.println("</FORM>");
out.println("<BODY>");
out.println("</HTML>");
buff.close();
}catch (IOException e) {
//-------ERROR---------
out.println("<HTML><BODY>");
out.println(e.getMessage());
out.println("<br> :<ahref+\"http://localhost/servlets/main\">");
out.println("Go to main");
out.println("</a>");
out.println("</HTML></BODY>");
}
// then--------------
out.close();
}
}
The problem is in the process_del servlet where I have to define this process when your option is delete somebody from the table.
Thanks in advance.