Actually I think that
Tomcat does a scan of webapps when it first starts up, and checks each directory to see if it has a WEB-INF subdirectory with a web.xml descriptor. So when a request comes in, Tomcat already knows if there is a corresponding web application. During that initial scan Tomcat can locate and expand WAR files also.
Bill