web.xml How to forward to html file after using /*

html, servlets, tomcat, web.xml

Solution

Is there a Tomcat-servlet to point to (in the part) which handles file reads?

It's the `DefaultServlet`. As you can see in its documentation, its servlet name is `default`.

So, this should do, provided that those static files are in `/static` folder:

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/static/*</url-pattern>
</servlet-mapping>

Beware however, older Tomcat versions have a security bug whereby all contents of `/WEB-INF` and `/META-INF` are publicly accessible when (ab)using the default servlet this way.

See also:

- How to access static resources when mapping a global front controller servlet on /*

Problem

I am using a servlet which has this mapping (to a vaadin servlet actually) ``` <servlet-mapping> <servlet-name>my Application</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> ``` I want to make an exception for some html files that I have. It is ok if these are in a subfolder. How do I do that? Is there a Tomcat-servlet to point to (in the part) which handles file reads? Rob

Original source

Related problems