new to servlet programing

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql.*;

import java.io.*;

public class pgm extends HttpServlet

{

Connection con;

Statement st=null;

public void doGet(HttpServletRequest req,

HttpServletResponse res)

throws ServletException, IOException

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:odbc:sri","scott","tiger");

String s1=req.getParameter("fn");

String s2=req.getParameter("ln");

String s3=req.getParameter("ph");

String s4=req.getParameter("ci");

String s5=req.getParameter("fn");

String s6=req.getParameter("pw");

st=con.createStatement();

int i=0;

i=st.executeUpdate("insert into data values(s1+","+s2+","+s3+","+s4+","+s5+","+s6)");

}

catch (SQLException se) {

System.out.println("We got an exception while executing our query:" +

"that probably means our SQL is invalid");

se.printStackTrace();

System.exit(1);}

PrintWriter pw=res.getWriter();

pw.println("Added successfully");

}

}

this is the sample project of reading from a html page and storing in database.while compiling this i am getting class not found exception and other errors like object does not exist. some one please help

[1395 byte] By [sria] at [2007-11-27 6:00:54]
# 1
Can you post the exceptions and stack trace?And also, please use code tags, makes the code easier to read.
nogoodatcodinga at 2007-7-12 16:39:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

well probably you need to add the servlet classes to your classpath because that is one problem posted at least five times a day.

If you are using Tomcat, add the tomcat/common/lib/servlet-api.jar to your classpath.

If you are using any application server, add the j2ee.jar to your classpath. Check the documentation of your application server where to find this jar.

In the future when posting a problem:

1) add the errors you are getting, including full stacktrace if available! People here cannot read minds nor do they have a crystal ball

2) use a meaningful topic title, "new to servlet programming" says so little to the rest of us

3) use the [ code ] formatting tag when posting code to make it easier to read. You can find the "code" button above the input area when creating a post.

Hope that solves all your problems.

gimbal2a at 2007-7-12 16:39:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Also, make sure that your versions are correct .. ie tomcat and java.Some versions of java will not work on some version of tomcat... This will cause a class error if not compatible
gokala at 2007-7-12 16:39:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...