How to map a url path to a specific resource on the filesystem in XML config with Jetty?

Viewed 26

I'm trying to map a specific URL /the-url to a static resource on the file system {WAR}/static/file.html using web.xml with Jetty 9.4.41.

I thought this would be relatively simple to figure out but I can't find anything relevant in the jetty docs or find any examples of doing this in web.xml. I've been trying to find the possible options for <servlet> in the hope that there's an option that will help to do this.

I know that I can map resources to exact names as in the URLs using the default Jetty servlet e.g.

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

...but I'm looking to do something like:

<servlet-mapping>
    <servlet-name>MySpecificResource</servlet-name>
    <url-pattern>/the-url</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>MySpecificResource</servlet-name>
    <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
    <!-- Something here so that DefaultServlet knows to serve /static/file.html ?? -->
</servlet>
0 Answers
Related