Есть томкат в директории %CATALINA_HOME%\webapps\ROOT есть файл index2.jsp в нем такой код
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Users</title>
</head>
<body>
<h2>Users List</h2>
<p><a href='<c:url value="/create" />'>Create new</a></p>
<table>
<tr><th>NickName</th><th>Password</th><th>email</th></tr>
<c:forEach var="user" items="${users}">
<tr><td>${users.nickname}</td>
<td>${users.password}</td>
<td>${users.email}</td>
<td>
<a href='<c:url value="/edit?id=${user.id}" />'>Edit</a> |
<form method="post" action='<c:url value="/delete" />' style="display:inline;">
<input type="hidden" name="id" value="${user.id}">
<input type="submit" value="Delete">
</form>
</td></tr>
</c:forEach>
</table>
</body>
</html>
HTTP Status 404 – Not Found
Type Status Report
Message /create
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.23
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author User
*/
@WebServlet("/create")
public class CreateServlet extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
getServletContext().getRequestDispatcher("/create.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
String nickname = request.getParameter("nickname");
String password = request.getParameter("password");
String email = request.getParameter("email");
Users users = new Users(nickname, password,email);
UsersDB.insert(users);
response.sendRedirect(request.getContextPath()+"/index");
}
catch(Exception ex) {
getServletContext().getRequestDispatcher("/create.jsp").forward(request, response);
}
}
}
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author User
*/
@WebServlet("/")
public class IndexServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ArrayList<Users> users = UsersDB.select();
request.setAttribute("users",users);
getServletContext().getRequestDispatcher("/index2.jsp").forward(request, response);
}
}