JSP/JDBC: HTTP Status 404 - Not Found
<p>I am having HTTP Status 404 - Not Found.</p>

<p>I am using Netbeans IDE and Glassfish sever and MySql as database.
I am unable to understand why I am having the error. 
Here are my codes.I am a beginner.</p>

<p>Thanks!</p>

<p><strong>This is my JSP file:</strong></p>

<pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
    &lt;title&gt;User Application Registration&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;Registration Page&lt;/h1&gt;
    &lt;form action="ServletRegister" method="post"&gt;
        Name: &lt;input type="text" name="name"&gt;&lt;br/&gt;
        Password: &lt;input type="password" name="password"&gt;&lt;br/&gt;
        Email: &lt;input type="text" name="email"&gt;&lt;br/&gt;
        Language: &lt;select name="language"&gt;
            &lt;option&gt;Hindi&lt;/option&gt;
            &lt;option&gt;English&lt;/option&gt;
            &lt;option&gt;Bengali&lt;/option&gt;
        &lt;/select&gt;&lt;br/&gt;
        &lt;input type="submit" value="Submit"/&gt;
    &lt;/form&gt;
&lt;/body&gt;
</code></pre>

<p></p>

<p><strong>This is my Servlet file:</strong></p>

<pre><code>package RegisterPackage;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletRegister extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {



    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    String n = request.getParameter("name");
    String p = request.getParameter("password");
    String e  = request.getParameter("email");
    String l = request.getParameter("language");

    try {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/demo", "root", "root");
        PreparedStatement ps = con.prepareStatement("insert into userdetails values(?,?,?,?)");

        ps.setString(1, n);
        ps.setString(2, p);
        ps.setString(3, e);
        ps.setString(4, l);

        int i = ps.executeUpdate();
        if (i &gt; 0)
            out.print("You are successfully registered!");
    } 
    catch (Exception e2) {
        System.out.println(e2);
    }
    out.close();  
}
</code></pre>

<p>}</p>

<p><strong>This is web.xml:</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"&gt;
    &lt;servlet&gt;
        &lt;servlet-name&gt;ServletRegister&lt;/servlet-name&gt;
        &lt;servlet-class&gt;RegisterPackage.ServletRegister&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;ServletRegister&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/ServletRegister&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;session-config&gt;
        &lt;session-timeout&gt;
            30
        &lt;/session-timeout&gt;
    &lt;/session-config&gt;
&lt;/web-app&gt;
</code></pre>

<p><strong>Directory structure in NetBeans:</strong></p>

<p><a href="https://i.stack.imgur.com/jV54q.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jV54q.jpg" alt="enter image description here"></a></p>

<p><strong>My Output:</strong></p>

<p><a href="https://i.stack.imgur.com/WQaWz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WQaWz.jpg" alt="enter image description here"></a></p>