I have a particular JSP which I would like to serve at the root page of my website (the URL "/"). All other requests should be served statically. So naturally I configured my web.xml like so:
<servlet>
<servlet-name>index</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>index</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Unfortunately it seems that <url-pattern>/</url-pattern> does not do what I need it to do. Instead of only handling the "/" URL, it is special-cased, and functions as the "default mapping", handling all requests not captured by other URL patterns.
In this particular case, the default servlet's <url-pattern>/*</url-pattern> handles all URLs. A request to "/" comes up as a 404, and the index servlet never gets invoked no matter what request is made.
Is there a way to explicitly map the "/" URL, and only that URL, to a particular servlet?
web.xml. Anyway it's solved, see below.