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>
I know that I can create a Java servlet that will load the file from the filesystem and serve it up, but since I don't need to make any modifications to the file, is there any way to have the XML config handle this for me and save me from cluttering my code base unnecessarily?