0

I'm programmatically (no web.xml) configuring a Tomcat 8 application and I'd like to load static assets (html, images, css, etc.) from the classpath.

I've done the equivalent for Jetty using ResourceHandler:

ResourceHandler resourceHandler = new ResourceHandler();
String webDir = getClass().getClassLoader().getResource("assets").toExternalForm();
resourceHandler.setResourceBase(webDir);

How exactly is this done in Tomcat?

digitalsanctum
  • 3,261
  • 4
  • 29
  • 43

1 Answers1

0

In java.lang.Class class having such a method's which load the assert pragmatically e.g.

 public URL getResource(String name)
 public InputStream getResourceAsStream(String name)
Shekhar Khairnar
  • 2,643
  • 3
  • 26
  • 44
  • Maybe I wasn't clear in my question. I'd like to specify a path to a directory in the classpath where assets are located. Not a single asset/file. – digitalsanctum Feb 14 '14 at 14:05