in src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java [449:496]
private Servlet resolveServletInternal(final SlingHttpServletRequest request,
final Resource resource,
final String scriptNameOrResourceType,
final ResourceResolver resolver) {
Servlet servlet = null;
// first check whether the type of a resource is the absolute
// path of a servlet (or script)
if (scriptNameOrResourceType.charAt(0) == '/') {
final String scriptPath = ResourceUtil.normalize(scriptNameOrResourceType);
if (scriptPath != null && isPathAllowed(scriptPath, this.executionPaths.get()) ) {
final Resource res = AbstractResourceCollector.getResourceOrNull(resolver,scriptPath,useResourceCaching);
servlet = this.getServlet(res);
if (servlet != null && !pathBasedServletAcceptor.accept(request, servlet)) {
if(LOGGER.isDebugEnabled()) {
LOGGER.debug("Servlet {} rejected by {} returning FORBIDDEN status", RequestUtil.getServletName(servlet),
pathBasedServletAcceptor.getClass().getSimpleName());
}
servlet = forbiddenPathServlet;
} else if (servlet != null && LOGGER.isDebugEnabled()) {
LOGGER.debug("Servlet {} found using absolute resource type {}", RequestUtil.getServletName(servlet),
scriptNameOrResourceType);
}
} else {
if ( request != null ) {
request.getRequestProgressTracker().log(
"Will not look for a servlet at {0} as it is not in the list of allowed paths",
scriptNameOrResourceType
);
}
}
}
if ( servlet == null ) {
// the resource type is not absolute, so lets go for the deep search
final AbstractResourceCollector locationUtil;
if ( request != null ) {
locationUtil = ResourceCollector.create(request, this.executionPaths.get(), this.defaultExtensions.get(), this.useResourceCaching);
} else {
locationUtil = NamedScriptResourceCollector.create(scriptNameOrResourceType, resource, this.executionPaths.get(), this.useResourceCaching);
}
servlet = getServletInternal(locationUtil, request, resolver);
if (servlet != null && LOGGER.isDebugEnabled()) {
LOGGER.debug("getServletInternal returns servlet {}", RequestUtil.getServletName(servlet));
}
}
return servlet;
}