3

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

bluevoid
  • 1,274
  • 13
  • 29

1 Answers1

8

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I am using tomcat 6, is that safe? Thanks for your complete answer :) – bluevoid Jul 05 '13 at 13:15
  • It's fixed since 6.0.30. See also [issue 50026](https://issues.apache.org/bugzilla/show_bug.cgi?id=50026), reported by yours truly. – BalusC Jul 05 '13 at 13:32