HTTP-статус 404 - не найден в Servlet crud - PullRequest
1 голос
/ 09 октября 2019

Я создаю простую систему crud в сервлете Java. Я новичок в Servlet. Я заполнил форму, нажал кнопку отправки и получил ошибку - HTTP Status 404 - Not Found. Я прикрепил снимок экрана ниже вместе с кодом.

enter image description here

структура папок

enter image description here

Форма

<form method = post action = "employee/employee.java">
           <table class="table table-borederd">
        <tr>
        <td>Enter Employee ID:</td>
                <td ><input class="form-control" type = "text" name = "txtEmpId"/></br></td>
        </tr>
        <tr>
        <td>Enter Employee FirstName:</td>
        <td ><input class="form-control" type = "text" name = "txtFName"/></td>
        </tr>
        <tr>
        <td>Enter Employee LastName:</td>
        <td ><input class="form-control" type = "text" name = "txtLName"/></td>
        </tr>
        <td><input type = "submit" value = "submit"/></td>
    </form>

employee.java

public class employee extends HttpServlet 
{  
    Connection con;
    int row;
    public void doPost(HttpServletRequest req, HttpServletResponse rsp) throws IOException, ServletException
        {
            try
            {
                Class.forName("com.mysql.jdbc.Driver");
                con = DriverManager.getConnection("jdbc:mysql://localhost/empp","root","");
                System.out.println("Connection Established");
            }
            catch(Exception e)
            {
                System.out.println("Sorry...........");
            }
            rsp.setContentType("text/html");
            PrintWriter out = rsp.getWriter();
            String empId = req.getParameter("txtEmpId");
            String empFName = req.getParameter("txtFName");
            String empLName = req.getParameter("txtLName");
            try
            {
            PreparedStatement stat = con.prepareStatement("insert into record (id,fname,lname)  Values(?,?,?)");
            stat.setString(1,empId);
            stat.setString(2,empFName);
            stat.setString(3,empLName);
            row = stat.executeUpdate();
            }
            catch(Exception e)
            {

            }
            out.println("<html>");
            out.println("<font color = 'red'>Sucessfully registered!</font>");
            out.println("</body>");
            out.println("<h2>");
            out.println(row);
            out.println("</h2>");
            out.println("</body>");
        }  

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...