User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Nov 2007
Location: Nigeria
Posts: 49
Reputation: tactfulsaint is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
tactfulsaint tactfulsaint is offline Offline
Light Poster

Servlet Package doses not exist...

  #1  
Jul 18th, 2008
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());
}
}
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Bangalore, India
Posts: 101
Reputation: ChaseVoid is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 10
ChaseVoid's Avatar
ChaseVoid ChaseVoid is offline Offline
Junior Poster

Re: Servlet Package doses not exist...

  #2  
Jul 18th, 2008
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Java Forum

All times are GMT -4. The time now is 5:56 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC