logger = logger.branch(TreeLogger.TRACE, "Request " + id + ": " + url,
null);
}
String servletClassName = null;
ModuleDef moduleDef = null;
try {
// Attempt to split the URL into module/path, which we'll use to see
// if we can map the request to a module's servlet.
RequestParts parts = new RequestParts(request);
if ("favicon.ico".equalsIgnoreCase(parts.moduleName)) {
sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND,
"Icon not available");
return;
}
// See if the request references a module we know.
moduleDef = getModuleDef(logger, parts.moduleName);
if (moduleDef != null) {
// Okay, we know this module. Do we know this servlet path?
// It is right to prepend the slash because (1) ModuleDefSchema requires
// every servlet path to begin with a slash and (2) RequestParts always
// rips off the leading slash.
String servletPath = "/" + parts.partialPath;
servletClassName = moduleDef.findServletForPath(servletPath);
// Fall-through below, where we check servletClassName.
} else {
// Fall-through below, where we check servletClassName.
}
} catch (UnableToCompleteException e) {
// Do nothing, since it was speculative anyway.
}
// BEGIN BACKWARD COMPATIBILITY
if (servletClassName == null) {
// Try to map a bare path that isn't preceded by the module name.
// This is no longer the recommended practice, so we warn.
String path = request.getPathInfo();
moduleDef = modulesByServletPath.get(path);
if (moduleDef != null) {
// See if there is a servlet we can delegate to for the given url.
servletClassName = moduleDef.findServletForPath(path);
if (servletClassName != null) {
TreeLogger branch = logger.branch(TreeLogger.WARN,
"Use of deprecated hosted mode servlet path mapping", null);
branch.log(
TreeLogger.WARN,
"The client code is invoking the servlet with a URL that is not module-relative: "
+ path, null);
branch.log(
TreeLogger.WARN,
"Prepend GWT.getModuleBaseURL() to the URL in client code to create a module-relative URL: /"
+ moduleDef.getName() + path, null);
branch.log(
TreeLogger.WARN,
"Using module-relative URLs ensures correct URL-independent behavior in external servlet containers",
null);
}