Embedding Tomcat 9 (with OpenJDK 11 on Windows 10) I want to serve
static files from `/foo/bar`. From scouring the web (primarily
https://stackoverflow.com/a/15235711/421049 ), the documentation, and
some books (primarily _Apache Tomcat 7_), I have this:
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir("/foo");
Context ctx = tomcat.addContext("", "/foo/bar");
final Wrapper defaultServlet = ctx.createWrapper();
defaultServlet.setName("default");
defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
defaultServlet.addInitParameter("debug", "1");
defaultServlet.addInitParameter("listings", "false");
defaultServlet.setLoadOnStartup(1);
ctx.addChild(defaultServlet);
ctx.addServletMappingDecoded("/", "default");
ctx.addWelcomeFile("index.html");
tomcat.start();
tomcat.getServer().await();
Everything looks like it starts up:
Apr 19, 2019 2:18:09 PM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service [Tomcat]
Apr 19, 2019 2:18:09 PM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.19]
Apr 19, 2019 2:18:10 PM
org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creation of SecureRandom instance for session ID
generation using [SHA1PRNG] took [281] milliseconds.
Apr 19, 2019 2:18:10 PM org.apache.catalina.core.ApplicationContext log
INFO: default: DefaultServlet.init: input buffer size=2048, output
buffer size=2048
But connections to http://localhost:8080/ time out. (I'm pretty sure but
not positive that I don't have anything blocking this in the firewall.)
Is there some simple thing I'm missing to connect things together?
Thanks,
Garret
P.S. The documentation on the web for the details of this is
surprisingly sparse.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org