First, you need to know that Servlet containers (I'll assume Jetty too) have a Servlet for rendering JSPs. This Servlet is typically extension mapped to *.jsp
.
The Servlet Specification gives the order of url-pattern
matching
- The container will try to find an exact match of the path of the request to the path of the servlet. A successful match selects the servlet.
- The container will recursively try to match the longest path-prefix. This is done by stepping down the path tree a directory at a time, using the ’/’ character as a path separator. The longest match determines the servlet selected.
- If the last segment in the URL path contains an extension (e.g. .jsp), the servlet container will try to match a servlet that handles requests for the extension. An extension is defined as the part of the last segment after the last ’.’ character.
- If neither of the previous three rules result in a servlet match, the container will > attempt to serve content appropriate for the resource requested. If a "default" servlet is defined for the application, it will be used. Many containers provide an implicit default servlet for serving content.
In your case, when you forward to
/WEB-INF/jsp/index.jsp
The Servlet container will match that path to your DispatcherServlet
mapped to
/*
This happens before the container could match the JSP servlet mapped to *.jsp
.
It therefore uses your DispatcherServlet
to service(..)
the request. But your DispatcherServlet
does not have a handler for
/WEB-INF/jsp/index.jsp
The simple solution would be to map your DispatcherServlet
to
/
and have it be the fallback Servlet
if no match is found.