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 code

Insert Data

<!-- Give Servlet reference to the form as an instances  
GET and POST services can be according to the problem statement-->
    <!-- Create an element with mandatory name attribute, 
    so that data can be transfer to the servlet using getParameter() -->
    <br/><br/><br/> import;
 import java.sql.DriverManager; 
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
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 

           // Close all the connections 

           // 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) { 


please provide the solution to my problem

New contributor

Kashish Shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.