Abhay,
  Herez the code.....I ahd run this before some two months back.Now itz not
running.
lllly many servlets r not wrkg.
Thanx..,RS.
// drop.java

import java.lang.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.awt.*;

public class drop extends HttpServlet {
String jdbc_class,jdbc_url,query,query1,ename,q1,q2,q3,q4,q5,passwd;
  /**
   * Initialize global variables
   */
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    jdbc_class = ("sun.jdbc.odbc.JdbcOdbcDriver");
   jdbc_url = "jdbc:odbc:Test";
  }

  /**
   * Service the request
   */
 public void service(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {

 boolean flag = false,a=false;
    Enumeration e;
    Connection con;
    res.setContentType("text/html");
    ResultSet rs,rs1;
    PrintWriter out = res.getWriter();

  try{
    Class.forName(jdbc_class);
    con = DriverManager.getConnection(jdbc_url," "," ");
    Statement stmt = con.createStatement();
      Statement stmt1 = con.createStatement();
      Statement stmt2 = con.createStatement();
      Statement stmt3 = con.createStatement();
      Statement stmt4 = con.createStatement();
      Statement stmt5 = con.createStatement();
    String enames = req.getParameter("listbox");


file://task deletion
 if(enames != null)
  {
  q1="delete from task  where tdes in (select tdes from emptask where ename
='"+enames+"')";
  stmt1.executeUpdate(q1);

file://taskname deletion
 q2="delete from emptask where emptask.ename = '"+enames+"' ";
 stmt2.executeUpdate(q2);

file://project deletion
  q3="delete from operation where operation.ename ='"+enames+"'";
  stmt3.executeUpdate(q3);

file://projectname deletion
  q4="delete from empproject  where  empproject.ename = '"+enames+"' ";
  stmt4.executeUpdate(q4);

file://name deletion
  q5="delete from login where ename ='"+enames+"'";
  stmt5.executeUpdate(q5);
}

query1 = "select ename from login";
rs = stmt1.executeQuery(query1);

out.println("<script language=\"javascript\">");
out.println("function validation(){document.forms[0].listname.value =
document.forms[0].listbox.value;}");
out.println("</script></head><body bgcolor=#dcdcdc>");
out.println("<form action=http://ts_pc_037:8080/servlet/drop1 method=get>");
out.println("<br><br><br><center><table border=3>");
out.println("<tr><td align=right bgcolor=#008080>");
out.println("<font color=#FFFFFF face=Arial>Employee Name</font></td>");
out.println("<td><font face=Arial>");

out.println("<select name=\"listbox\" onSelect=\"  validation()\">");
out.println("<option>");
while(rs.next())
  {
  enames = rs.getString("ename");
  out.println("<option
value='"+enames+"'>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp"+enames+"&nbsp&nbsp&n
bsp&nbsp&nbsp&nbsp&nbsp</option>");
  }
out.println("</select><input type=\"hidden\" name=\"listname\"
value=\"\">");
out.println("</table></center>");

out.println("<center><table><tr><td><font color=#FFFFFF><p><font
face=Arial>");
out.println("<input type=\"submit\" value=\"  Drop  \" name=\"Button1\"
color=#008080>");
out.println("</font></td></form>");

out.println("<center><form action=\\menu.html>");
out.println("<td><input type=\"submit\" value=\"  Back  \"></td></form>");
out.println("</table></center></body></html>");

}catch (SQLException ex) {
  out.println("<hr><h3>*** Error  Caught***<h3><p>");
}
 catch (ClassNotFoundException ex) {
     out.println("<hr><h3>*** ClassNotFoundException caught ***<h3><p>");
     out.println(jdbc_class + " not found.");
     out.println(ex.getMessage());}
  catch (java.lang.Exception ex){
     ex.printStackTrace();}

// out.println("<HTML><HEAD><meta http-equiv=\"refresh\" content=\"3;
url=\"http://ts_pc_014:8080/servlet/drop method=post\"></head></html>");
} }

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to