I have deployed my application (todo.war
) into Tomcat v10.0.5. I expected that http://localhost:8080/todo/
would bring me to /jsp/index.jsp
, but I am getting a 404 response instead.
Here is my application's layout:
todo.war
├── META-INF
│ └── MANIFEST.MF
├── WEB-INF
│ ├── classes
│ │ └── com
│ │ └── ciaoshen
│ │ └── sia
│ │ └── demo
│ │ └── gradle_demo
│ │ └── todo
│ │ ├── model
│ │ │ └── ToDoItem.class
│ │ └── web
│ │ └── ToDoServlet.class
│ ├── lib
│ │ └── jstl-1.2.jar
│ └── web.xml
├── css
└── jsp
├── all.jsp
└── index.jsp
So in web.xml
file, servlet-mapping pattern /
is bound to ToDoServlet
,
<servlet-mapping>
<servlet-name>ToDoServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
and ToDoServlet.java
dispatched the path /
to /jsp/index.jsp
file.
private String processRequest(String servletPath, HttpServletRequest request) {
if (servletPath.equals("/")) {
return "/jsp/index.jsp";
} else if (servletPath.equals("/all")) {
// ... other direction
} else {
// ... other direction
}
}
but got 404
resource not found in browser,
my index.jsp
is very simple,
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head><title>First JSP</title></head>
<body>
<h2>--- To Do Application ---</h2>
<h2>Please make a choice:</h2>
<h2><a href="/all"> (a)ll items</a></h2>
</body>
</html>
Can someone explain what I'm missing?