Thanks for ur reply,but I have still not found the solution for my problem.
I have followed ur advice, but as soon as the servlet is called it shows me the error 'class not found'.
Actually at the time of compilation it gave me no error but at the run time it displayed the error on the screen.
I am enclosing my code so that u can help me out.Please give ur advice .
---------------------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
public class sjvtechfin1 extends HttpServlet
{
String type[];
String typ,per,amount,formven,val;
int uid;
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
doPost(request,response);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
type = new String[5];
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<html><head></head><body>");
Enumeration parameters = request.getParameterNames();
String param = null;
uid = 012;
out.println("Welcome user "+uid+"<br>");
while (parameters.hasMoreElements())
{
param=(String)parameters.nextElement();
type[0]=param;
type[1]=param;
type[2]=param;
type[3]=param;
try
{
out.println("Swati <br>");
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/iba");
if (con!=null)
{
out.println("Swati");
Statement statement=con.createStatement();
PreparedStatement ps = con.prepareStatement("insert into sjvtechfin values(?,?,?,?,?)");
ps.setInt(1,uid);
ps.setString(2,type[0]);
ps.setString(3,type[1]);
ps.setString(4,type[3]);
ps.setString(5,type[2]);
ps.executeUpdate();
out.println("Swati");
}
}
catch (Exception ds)
{
out.println("error:"+ds);
}
out.println(param+":"+request.getParameter(param)+"<br>");
}
out.println("</body></html>");
out.close();
}
public String getServletInfo()
{
return "BasicServlet Information";
}
}
----------------------------
Waiting for ur reply.
Swati
Originally posted by Raukutam Sandeep:
Design u'r form just with HTML tags only and save the page with .html extension.
In action property of the form tag, give the path to .class(servlet) file.
As soon as u submit the form, it will look for the .class i.e., servlet file.
In the servlet write the code for inserting the values in a database. I think u know how to insert values in a database by retrieving the values from the form fields(using getParameter method of HttpServletRequest)...
Try this and get back...
Good luck!!!
regds,
Sandeep.