import javax.servlet.*;
import javax.servlet.http.*;

these servlet package does not exist, any idea

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class EmployeeDetails extends HttpServlet{

static int i;
Connection con;
PrintWriter out;
ResultSet rs;
public void ini(){

i=0;
con=null;
out=null;
rs=null;
}
public void doGet(HttpservletRequest request, HttpServletResponse respose) throws ServletException,IOException{

i++;
out=response.getwriter();
out.println("<b>your are user no."+ i +" to visit this site.</b><br><br>");

try{
Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
con.DriverManager.getConnection("jdbc:odbc:EmployeeDB","test","password");


PreparedStatement pstm=null;
String query=null;


query ="select emp_fname, address,age, desig from Employee_Master where id=?";

pstm=con.prepareStatement(query);
pstm.setInt(1,Integer.parseInt(request.getParameter("id")));
rs=pstm.executeQuery();
out.println("<b><center>Employee Details</center></b><br><br>");


ResultSetMetaData rsmd=rs.getMetaData();

int colcount=rsmd.getColunmCount();
out.println("<table align = center border=1 cellpadding=2>");

out.println("<tr>");


for (int i=1; i<=colcount;i++)
{
out.println("<th>"+rsmd.getColunmLabel(i)+"</th>");
}
out.println("</tr>");

while(rs.next()){
out.println("<tr>");
out.println("<td>"+rs.getString("emp_fname") +"</td>");
out.println("<td>"+rs.getString("address") +"</td>");
out.println("<td>"+rs.getString("age") +"</td>");
out.println("<td>"+rs.getString("desig")+"</td>");
out.println("</tr>");
}

out.println("</table>");
out.println("</body>");
}
catch(Exception e)
{
out.println(e.toString());
}
}
public void destroy(){
try{
i=0;
con.close();
out.close();
rs.close();
}
catch(SQLException se){
out.println(se.toString());
}
}
}

hymm, it should be present. Either way which version of JDK are you using? I think you need the J2EE verson. Servelets are related to jsp pages and applets, right.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.