Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

on submitting getting an error HTTP Status 404 - Not Found [closed]

$
0
0

error on clicking submit button: HTTP Status 404 - Not Foundtype Status report

messageNot Found

descriptionThe requested resource is not available.

GlassFish Server Open Source Edition 4.1.1

getting this error

Here's the codeindex.html

Insert Data

<!-- Give Servlet reference to the form as an instances  GET and POST services can be according to the problem statement--><p>ID:</p>  <!-- Create an element with mandatory name attribute,     so that data can be transfer to the servlet using getParameter() --><br/> <p>String:</p>  <br/><br/><br/> 
InsertData.java import java.io.IOException; import java.sql.DriverManager; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; // Servlet Name@WebServlet("/InsertData")public class InsertData extends HttpServlet {     private static final long serialVersionUID = 1L;protected void doPost(HttpServletRequest        request,HttpServletResponse response)throws ServletException, IOException{    try {        Class.forName("com.mysql.jdbc.Driver");Connection    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");        PreparedStatement st = con.prepareStatement("insert into demo values(?, ?)");           // For the first parameter,            // get the data using request object            // sets the data to st pointer            st.setInt(1, Integer.valueOf(request.getParameter("id")));            // Same for second parameter            st.setString(2, request.getParameter("string"));            // Execute the insert command using executeUpdate()            // to make changes in database            st.executeUpdate();            // Close all the connections            st.close();            con.close();            // Get a writer pointer             // to display the successful result            PrintWriter out = response.getWriter();            out.println("<html><body><b>Successfully Inserted"+"</b></body></html>");     }     catch (Exception e) {         e.printStackTrace();     } } 

}

please provide the solution to my problem


Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>