You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Felix Meschberger <fm...@gmail.com> on 2008/01/28 08:57:22 UTC

WebDAV and executed scripts

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


Re: WebDAV and executed scripts

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Jan 28, 2008 8:57 AM, Felix Meschberger <fm...@gmail.com> wrote:

> ...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....

Seems reasonable, though I haven't seen enough concrete use cases to
be really convinced that executing scripts directly is a good thing.

And the resulting something.jsp.html URLs are kind of ugly - but I
don't have a better proposal at this point, so I'm ok with what you
suggest.

-Bertrand