Hi all, With the new resource tree mechanism built in last week, it now becomes possible to directly address scripts (and servlets) and have them executed on the server. This has its advantages in certain aspects, such as not requiring a sentinel repository node to be able to implement administrative stuff.
Of course, there is also another side to it: By executing directly addressed scripts we are not able any more to access such scripts for raw delivery. This is a problem in two areas: (1) WebDAV, where we would like to access the script source and not have the script executed and (2) client side JavaScript which must be sent as the source and not be executed on the server. As a solution to this problem, I propose to only execute directly addressed scripts if the request extension (RequestPathInfo.getExtension()) is not null. If the request extension is null, the directly addressed script is not executed. Example: Consider a script stored in the repository at /sling/root/sample.js. If the script is requested with the URL http://host/sling/root/sample.js, the script is not executed because the request extension is null. If the script is requested with the URL http://host/sling/root/sample.js.html, the script is executed because the request extension is "html". This would be implemented such that the ServletResolver, which is intended to check whether to use the addressed resource as the script, only considers the resource if the request extension is null, e.g. something like this: SlingServletResolver.resolveServlet(SlingHttpServletRequest request) { // new: enable script execution of directly addressed scripts // but only if extension is not null if (request.getRequestPathInfo().getExtension() != null) { Servlet result = request.getResource().adaptTo(Servlet.class); if (result != null) { return result; } } // continue servlet resolution by resource type .... } WDYT ? Regards Felix
