Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes servlet help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet help me" Watch "servlet help me" New topic
Author

servlet help me

janet ilieva
Greenhorn

Joined: Feb 02, 2001
Posts: 11
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.
Could somebody to help me?
Thanks.
janet ilieva
Greenhorn

Joined: Feb 02, 2001
Posts: 11
Anybody??? I need some ideas.
Steve Chernyak
Ranch Hand

Joined: Oct 19, 2000
Posts: 113
Could you please be more specific.
post your HTML form and maybe something from the servlet.
SteveC
janet ilieva
Greenhorn

Joined: Feb 02, 2001
Posts: 11
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.

janet ilieva
Greenhorn

Joined: Feb 02, 2001
Posts: 11

Originally posted by Steve Chernyak:
Could you please be more specific.
post your HTML form and maybe something from the servlet.
SteveC

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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet help me