1

I use J2EE Servlet and tomcat server 7.0.42 and eclipse(kepler version), i want insert data from html page and insert this information into mysql table after the submit button pressed the following error are generated.

    **Error After Submit button is pressed 
   HTTP Status 404 -
   type Status report message
   description The requested resource is not available.
   Apache Tomcat/7.0.42**

   InsertData.java ( Servlet class )

here is the java class for servlet and i create the database connection in this file and access the data from html page.

 package demo; 

 public class InsertData extends HttpServlet
 {
 public void doGet(HttpServletRequest request, HttpServletResponse response)
 throws IOException, ServletException
 {   
 String t1= request.getParameter("text1");
 String t2= request.getParameter("text2");
 String t3= request.getParameter("text3");
 String t4= request.getParameter("text4");

 Connection con=null;   
 try
 {
  Class.forName("com.mysql.jdbc.Driver");            
  con=DriverManager.getConnection
  ("jdbc:mysql://localhost:3306/servlet_demo","root","");


   java.sql.Statement stmt =con.createStatement(); 

   String sql= "INSERT INTO demo(text1,text2,text3,text4)
   VALUES('"+t1+"','"+t2+"','"+t3+"','"+t4+"')" ;
  stmt.executeQuery(sql);  
  con.close(); 

  }
 catch(SQLException sx)
 {
 out.println(sx);
  }
 catch(ClassNotFoundException cx)
 {
 out.println(cx);
  }
 }
  }
Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Ravikumar
  • 11
  • 1
  • 4

1 Answers1

0

make sure your web.xml has the servlet entry...and the web app is deployed in the tomcat

abby
  • 125
  • 1
  • 2
  • 6