+ "<br/>This utility does not take this into account and uses the first dot to split"
+ " between path and selectors/extension."
+ "<br/>As a workaround, you can replace dots with underline characters, for example, when testing such an URL."
+ "</em>";
ResourceResolver resourceResolver = null;
try {
resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
final PrintWriter pw = response.getWriter();
pw.print("<form method='get'>");
pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
titleHtml(
pw,
"Servlet Resolver Test",
"To check which servlet is responsible for rendering a response, enter a request path into " +
"the field and click 'Resolve' to resolve it.");
tr(pw);
tdLabel(pw, "URL");
tdContent(pw);
pw.print("<input type='text' name='");
pw.print(PARAMETER_URL);
pw.print("' value='");
if ( url != null ) {
pw.print(ResponseUtil.escapeXml(url));
}
pw.println("' class='input' size='50'>");
closeTd(pw);
closeTr(pw);
closeTr(pw);
tr(pw);
tdLabel(pw, "Method");
tdContent(pw);
pw.print("<select name='");
pw.print(PARAMETER_METHOD);
pw.println("'>");
pw.println("<option value='GET'>GET</option>");
pw.println("<option value='POST'>POST</option>");
pw.println("</select>");
pw.println(" <input type='submit' value='Resolve' class='submit'>");
closeTd(pw);
closeTr(pw);
if (StringUtils.isNotBlank(url)) {
tr(pw);
tdLabel(pw, "Decomposed URL");
tdContent(pw);
pw.println("<dl>");
pw.println("<dt>Path</dt>");
pw.print("<dd>");
pw.print(ResponseUtil.escapeXml(requestPathInfo.getResourcePath()));
pw.print("<br/>");
pw.print(CONSOLE_PATH_WARNING);
pw.println("</dd>");
pw.println("<dt>Selectors</dt>");
pw.print("<dd>");
if (requestPathInfo.getSelectors().length == 0) {
pw.print("<none>");
} else {
pw.print("[");
pw.print(ResponseUtil.escapeXml(StringUtils.join(requestPathInfo.getSelectors(), ", ")));
pw.print("]");
}
pw.println("</dd>");
pw.println("<dt>Extension</dt>");
pw.print("<dd>");
pw.print(ResponseUtil.escapeXml(requestPathInfo.getExtension()));
pw.println("</dd>");
pw.println("</dl>");
pw.println("</dd>");
pw.println("<dt>Suffix</dt>");
pw.print("<dd>");
pw.print(ResponseUtil.escapeXml(requestPathInfo.getSuffix()));
pw.println("</dd>");
pw.println("</dl>");
closeTd(pw);
closeTr(pw);
}
if (StringUtils.isNotBlank(requestPathInfo.getResourcePath())) {
final Collection<Resource> servlets;
Resource resource = resourceResolver.resolve(requestPathInfo.getResourcePath());
if (resource.adaptTo(Servlet.class) != null) {
servlets = Collections.singleton(resource);
} else {
final ResourceCollector locationUtil = ResourceCollector.create(
resource,
requestPathInfo.getExtension(),
executionPaths,
defaultExtensions,
method,
requestPathInfo.getSelectors());
servlets = locationUtil.getServlets(resourceResolver);
}
tr(pw);
tdLabel(pw, " ");
tdContent(pw);
if (servlets == null || servlets.isEmpty()) {
pw.println("Could not find a suitable servlet for this request!");
} else {
pw.print("Candidate servlets and scripts in order of preference for method ");
pw.print(ResponseUtil.escapeXml(method));
pw.println(":<br/>");
pw.println("<ol class='servlets'>");
outputServlets(pw, servlets.iterator());
pw.println("</ol>");
}
pw.println("</td>");
closeTr(pw);
}
pw.println("</table>");
pw.print("</form>");
} catch (LoginException e) {
throw new ServletException(e);
} finally {
if (resourceResolver != null) {
resourceResolver.close();
}
}
}