•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 426,512 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,119 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 183 | Replies: 1 | Solved
![]() |
•
•
Join Date: Nov 2007
Location: Nigeria
Posts: 49
Reputation:
Rep Power: 1
Solved Threads: 0
import javax.servlet.*;
import javax.servlet.http.*;
these servlet package does not exist, any idea
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());
}
}
}
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the Java Forum
- Previous Thread: Aggregating CSV values
- Next Thread: animation and threads


Linear Mode