May 10, 2020
Estimated Post Reading Time ~

Sling URL Resolution

Sling looks up the resource identified by the URL i.e. the value for the sling:resourceType property which defines the resource type of that resource.

If the resource path is relative, it first finds in apps then in libs.

internally, Sling only handles with Servlets

Each resource type may have a resource supertype
If a resource type has no explicit resource supertype, the resource supertype is assumed to be “sling/servlet/default”.

GET and HEAD request methods are treated differently than the other request methods. Only for GET and HEAD requests will the request selectors and extension be considered for script selection. For other requests, the servlet or script name (without the script extension) must exactly match the request method.
That is for a PUT request, the script must be PUT.esp or PUT.jsp. For a GET request with a request extension of html, the script name may be html.esp or GET.esp.

If URL is http://host:port/resource.selector1.selector2.html
Priority of the script selection would be:

  • selector1/selector2.html.jsp
  • selector1/selector2.jsp
  • selector1.html.jsp
  • selector1.esp
  • html.jsp
  • resource.jsp
  • GET.jsp
To test the same: https://www.dropbox.com/s/3hzcapbblm03gim/slingresolution.zip?dl=0Try http://localhost:4502/content/testpage.selector1.selector2.html

The rules for script path prioritization is defined as follows:
The more request selectors are matched, the better
A script including the request extension matches better than one without a request extension (for html only)
A script found earlier matches better than a script found later in the processing order. This means, that script closer to the original resource type in the resource type hierarchy is considered earlier.

Sling Post Servlet
http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#multiple-ways-to-modify-content


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.