Servlet
when i add the following xml code to the web.xml it throws the same error
<web-app>
<servlet>
<servlet-name>InsertServlet</servlet-name>
<servlet-class>InsertServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>InsertServlet</servlet-name>
<url-pattern>/InsertServlet</url-pattern>
</servlet-mapping>
</web-app>
The Error is
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\website_app\WEB-I
NF\classes>java InsertServlet
Exception in thread "main" java.lang.NoClassDefFoundError: InsertServlet
The coding for the InsertServlet is
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class InsertServlet extends HttpServlet{
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
res.setContentType("Registration/html");
int count=0;
PrintWriter out = res.getWriter();
String FirstName=req.getParameter("FirstName");
String LastName=req.getParameter("LastName");
String Email=req.getParameter("Email");
String Password=req.getParameter("Password");
String ConformPassword=req.getParameter("ConformPassword");
String Dateofbirth=req.getParameter("Dateofbirth");
int Age=Integer.parseInt(req.getParameter("Age"));
String Gender=req.getParameter("Gender");
String Address=req.getParameter("Address");
String Country=req.getParameter("Country");
String State=req.getParameter("State");
String City=req.getParameter("City");
int Telephone=Integer.parseInt(req.getParameter("Telephone"));
int Mobile=Integer.parseInt(req.getParameter("Mobile"));
String Howdidyouhear=req.getParameter("Howdidyouhear");
PreparedStatement pstm=null;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver ");
String connectionUrl = ("jdbc:sqlserver://localhost:1433;database=sree;integratedSecurity=true");
Connection con = DriverManager.getConnection(connectionUrl);
pstm=con.prepareStatement("insert into stureg(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pstm.setString(1,FirstName);
pstm.setString(2,LastName);
pstm.setString(3,Email);
pstm.setString(4,Password);
pstm.setString(5,ConformPassword);
pstm.setString(6,Dateofbirth);
pstm.setInt(7,Age);
pstm.setString(8,Gender);
pstm.setString(9,Address);
pstm.setString(10,Country);
pstm.setString(11,State);
pstm.setString(12,City);
pstm.setInt(13,Telephone);
pstm.setInt(14,Mobile);
pstm.setString(15,Howdidyouhear);
int i=pstm.executeUpdate();
if(i==1){
System.out.print("insert");
}
else{
System.out.print("not insert");
}
}
catch(Exception e){
e.getMessage();
}
}
}
View Answers
May 4, 2011 at 5:48 PM
servlet does not contain main method. And it does not run on console. It is run on tomcat server.
Follow these steps after compiling the servlet
1)Run Tomcat server by clicking the startup.bat file. This is located inside the bin folder of apache tomcat.
2)Open the browser and type the following url:
http://localhost:8080/website_app/InsertServlet
For more information, visit the following link and go through the examples:
http://www.roseindia.net/servlets/index.shtml
Related Tutorials/Questions & Answers:
ServletServlet how to navigate one
servlet page to another
servlet page
Advertisements
servletservlet is there any way to include pdf's in
servlet servletservlet How many times the
servlet is accessed
servletservlet what are the methods and interfaces in the
servlet api ?
Servlet Tutorials
servletservlet what are the all necessary configuration to run a
servlet servletservlet how to interact with a
servlet from a swing program
servletservlet I designed 1 html form & a
servlet but when I click on form I don't get output of
servlet Please help
servletservlet I designed 1 html form & a
servlet but when I click on form I don't get output of
servlet Please help
servletservlet i want to create a login page with
servlet using database mysql? only in
servlet not in jsp plzz help me out
Servlet override Service method in the
servlet when you extend GenericServlet to create
servlet as it is mandatory to override it. But, when you extend HttpServlet to create a
servlet then you can't override service method as there is a need to override
ServletServlet What must be implemented by all Servlets?
The
Servlet Interface must be implemented by all servlets
servletservlet how to create a login form using
servlet using submit,edit delete button
servletservlet dear sir
servlet and html not run on eclips plz help me
servletservlet i want a program for counting the no of times the
servlet has been invoked
servletservlet can i stoar record in variable which selected from table in
servlet servlet of the
Servlet API. It contains the classes necessary for a standard, protocol-independent
servlet. Every
servlet must implement the
Servlet interface in one
ServletServlet I want to know the steps to write a simple
servlet program... .
Hello Friend,
Follow these steps:
Put
servlet-api.jar inside the lib folder of apache tomcat.
1)create a
servlet.
import java.io.*;
import
Servlet Servlet Why is
Servlet so popular?
Because servlets are platform-independent Java classes that are compiled to platform-neutral byte code that can be loaded dynamically into and run by a Java technology-enabled Web
servletservlet i want to use
servlet application on my web page then what should i do. I have already webspace.
Hi Friend,
Please visit the following link:ADS_TO_REPLACE_1
Servlet Tutorials
Thanks
servletservlet how to read a file from different folder using filereader in
servlet
Hello Friend,
Please visit the following link:ADS_TO_REPLACE_1
http://www.roseindia.net/servlets/
servlet-read-file.shtml
Here you
ServletServlet Can a user defined function be included in a
servlet? I need information regarding
servlet syntax and not JSP.
Yes, you can create user defined function in Servlets.
Have a look at the following link:
http
servletservlet I want the full coding for uploading a file in local drive D usin jsp,java class and
servlet... help me thanks in advance....
... and
servlet please and thanks in advance
ServletServlet Hi,
Can any one please expalin me below topics
SERVLET ENGINE
2.WHY SUPER.INIT();
Thanks alot in advance!!
Regards:
Akash
servlet servlet Dear Deepak,
is it compulsary to write the sevice()
becoz i ve seen some example which does not ve sevice()..is it tue? plz replay me
with thanks
praveen
servletservlet plz can anyone give me the link of javax library jar file. i badly need that. thanks in advance
Please visit the following link:
Download
Servlet API
servletservlet I want a fully readymade project on online voting system with code in java
servlet and database backend as msaccess.can u plz send me as soon as possible
Servlet the same error
<web-app>
<servlet>
<
servlet-name>InsertServlet</
servlet-name>
<
servlet-class>InsertServlet</
servlet-class>
</servlet>
<
servlet-mapping>
<
servlet-name>
servlet servlet file which prints out the user's inputs. I need to use the post method to pass the data from html to the java
servlet and also use both doGet and doPost methods in the
servlet. I think, but unfortunately I have a terrible teacher
SERVLET to the
servlet and if the user id is correct then a new page will be displayed with his... pass to the
servlet and all the fields brlongs to that id will be appear... will be done by using jsp and
servlet... Plz help me,im really tensed...........
servletservlet hi sir,this is ashok.i installed tomcat 6.0 and jdk-150.i checked the server it's working but when execute
servlet program for the .class file it shows the errors javax.servlet is not exist.what can i do,please tell me
servlet to
servlet. So, if anyone can help me so I can see how to connect the two I would
servletservlet How do we define an application level scope for
servlet?
Application scope uses a single namespace, which means all your pages should be careful not to duplicate the names of application scope objects
servletservlet how to jsp integer are type cast int
servlet page
Hi Friend,
Try the following code:ADS_TO_REPLACE_1
1)form.jsp:
<form method="post" action="../Data">
Enter Number:<input type="text" name="num
servlet servlet try
{
con=DaoPack.createConnection();
}
catch(Exception e)
{
e.printStackTrace();
}
if(request.getParameter("addproduct")!=null)
{
ProductBean bean=new ProductBean
servlet servlet try
{
con=DaoPack.createConnection();
}
catch(Exception e)
{
e.printStackTrace();
}
if(request.getParameter("addproduct")!=null)
{
ProductBean bean=new ProductBean
servlet com.ilp.tsi.pm.services.StockService;
/**
*
Servlet implementation class AddServlet1
*/
//
Servlet for Adding the stock
public class AddStockServlet extends...;
import com.ilp.tsi.utils.*;
/**
*
Servlet implementation class Changepwd
servlet);
}
}
}
this is the code for .java
servlet am able to run
servlet com.ilp.tsi.um.bean.BankBean;
import com.ilp.tsi.um.service.BankService;
/**
*
Servlet