How Sling Resource Resolution is done in AEM
Sling Resource Resolution is the core mechanism that turns an incoming request into a resource, finds the matching component or script, and renders the final HTML response. In AEM as a Cloud Service, this flow is still based on Apache Sling, but the recommended implementation is modern: editable templates, HTL, Sling Models, Core Components, and immutable runtime assumptions.
This article explains the complete request flow using a practical page URL such as /content/mysite/us/en/products.html, and shows how Sling resolves the requested resource, determines its resource type, finds the correct script, and returns the response.
- End-to-end request flow
- URL, selectors, extension, and suffix
- ResourceResolver and resource resolution
- Resource type, servlet, and HTL script resolution
- Legacy AEM / AEM 6.5 differences
End-to-end request flow in AEM as a Cloud Service

- Browser Request – The browser sends a request such as
/content/mysite/us/en/products.html. - Sling Request Processing – Sling parses the request and identifies the resource path, selectors, extension, suffix, HTTP method, and query parameters.
- Resource Path – Sling extracts the resource path from the URL, for example
/content/mysite/us/en/products. - ResourceResolver – The
ResourceResolvermaps the resource path to the corresponding repository resource, such as/content/mysite/us/en/productsand itsjcr:contentnode. - Resource Type – Sling reads the resource’s
sling:resourceType, for examplemysite/components/page, to determine which component should handle the resource. - Servlet / Script Resolution – Sling finds the best matching servlet or rendering script based on the resource type, selectors, extension, HTTP method, and resource super type.
- Component Rendering – The selected component script, commonly an HTL script, renders the component and may use a Sling Model to prepare the required data.
- HTML Response – AEM generates the final HTML and returns the response to the browser.
This is the most important idea to keep in mind: Sling does not just open a file. It resolves a resource first, then resolves the best script to render that resource.
URL, selectors, extension, and suffix
Consider this request:
/content/mysite/us/en/products.html
| Part | Example | Meaning |
| Resource path | /content/mysite/us/en/products |
The content resource Sling tries to resolve. |
| Extension | html |
The output format requested by the browser. |
| Selectors | None in this example | Optional request modifiers that can influence script selection. |
| Suffix | None in this example | Optional extra path information after the extension. |
| Query string | Optional | Request data, not part of resource resolution. |
If you want to see selectors in action, the same page might be requested as /content/mysite/us/en/products.print.html. In that case, print becomes a selector, and Sling can choose a more specific script if one exists.
Important: selectors and suffixes help with script selection and request data, but they do not change the underlying repository resource unless your code explicitly interprets them.
ResourceResolver and resource resolution
When a request reaches AEM, Sling uses a ResourceResolver to map the request path to a repository resource. In AEM as a Cloud Service, this usually means:
- the request resolves to a page resource under
/content - the page resource points to its renderable content through
jcr:content - the
jcr:contentnode carries thesling:resourceTypethat identifies the component responsible for rendering
For example, a page at /content/mysite/us/en/products may resolve to a page content node whose resource type is something like mysite/components/page/product-page.
That resource type is the bridge between the content and the code. It tells Sling which component should render the resource.
In modern AEM projects, this usually means a component under /apps with HTL scripts and a Sling Model, rather than a JSP-based implementation.
Resource type, servlet, and HTL script resolution
After Sling resolves the resource, it resolves the best script or servlet to handle the request. The resolution process typically considers:
- Resource type – the component assigned to the resource
- Selectors – optional modifiers such as
printoramp - Extension – usually
htmlfor page rendering - Request method – such as GET or POST when a servlet is involved
- Resource super type – fallback inheritance if the exact component script is not found
A typical Cloud Service page rendering flow looks like this:
- The request targets
/content/mysite/us/en/products.html. - Sling resolves the page resource and reads its page component resource type.
- Sling searches for an HTL script that matches that resource type and the requested extension.
- If selectors are present, Sling prefers a more specific script such as
products.print.htmlbefore falling back toproducts.html. - If the exact script is missing, Sling can fall back through the resource super type chain.
This is why the final rendered file is not chosen by filename alone. Sling performs a layered resolution based on the request and the component model.
Practical example: /content/mysite/us/en/products.html
Here is a simplified real-world flow for a page request in AEM as a Cloud Service:
- The browser requests
/content/mysite/us/en/products.html. - The request reaches AEM through Dispatcher and the AEM runtime.
- Sling resolves the path to the page resource
/content/mysite/us/en/products. - Sling reads the page’s
jcr:contentnode. - The page content node exposes a
sling:resourceTypesuch asmysite/components/page/product-page. - Sling looks for the corresponding HTL script under that resource type.
- The HTL script often delegates logic to a Sling Model for data preparation.
- The component renders HTML, client-side assets load if needed, and the browser receives the response.
If the page uses selectors, the script choice can change without changing the underlying page content. For example, the same page might render a print view with a selector-specific script while keeping the same resource.
Selectors, extensions, and suffixes in practice
- Selectors refine script selection, such as
.print.htmlor.amp.html. - Extensions define the requested output format, such as
.html,.json, or.xml. - Suffixes carry extra path information, such as
/content/mysite/us/en/products.html/related. - Query parameters are request inputs, but they are not part of the repository path resolution.
These parts are important because they affect how Sling chooses the script, but they are not a replacement for a well-defined component resource type and HTL structure.
Modern AEM as a Cloud Service best practices
- Use editable templates and component resource types instead of legacy page implementation patterns.
- Keep rendering logic in HTL and Sling Models, not in the view layer.
- Use Core Components where possible and extend them through resource super types.
- Keep repository structure clean: content under
/content, code under/apps, policies under/conf. - Treat selectors and suffixes as deliberate request-routing tools, not as hidden business logic.
In AEM as a Cloud Service, the same Sling fundamentals still apply, but the implementation style is more modern and more constrained by immutable deployment practices.
Legacy AEM / AEM 6.5 differences
The core Sling resolution concept is the same in older AEM versions, but the surrounding implementation is different:
- Older projects often used JSP more heavily than HTL.
- Classic UI and older component patterns were more common.
- Development sometimes relied on legacy scripts or component structures that are less aligned with Cloud Service best practices.
- AEM as a Cloud Service favors HTL, Sling Models, Core Components, and modern repository organization.
If you maintain an older AEM 6.5 codebase, the request flow still starts with Sling Resource Resolution, but you may see JSP-based rendering or legacy component conventions more often. For new work, AEM as a Cloud Service should be treated as the primary reference model.
Summary: Sling resolves the request path to a resource, reads the resource type, selects the matching servlet or HTL script, renders the component, and returns the HTML response. Once you understand that flow, troubleshooting page rendering, selectors, and component behavior in AEM becomes much easier.
Leave a Reply