Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Sling Resource Resolution Preference

Avatar

Level 1

Hi all,

I've a base page component let's say homepage that contains 2 files. one is JSP, another html

sling-resolution.PNG

is referenced in homepage template. When I try to create a page using that template, it renders html files.

As far as I'm aware of, JSP takes preference over html so it should render JSP instead of html.

Please provide insight.

Regards,

Saurabh Pathak

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi Saurabh

      Sling Resolution is an important module in Sling. It is really important to understand the sling resolution before even starting AEM development. I have tried to explain the same here for a similar question here Template component can't override page.html . This explains how the files are resolved.

To answer your question simply,

     if the user request a content as --> <path>.<selector...>.<extension>

     then for the request resolution files ending with <selector>.<extension>.<script extension> takes priority

Always understand that selectors have maximum priority and the more selectors are matched the highest the priority. If selectors are not matched then the extension gets priority.

Here in your case sling priority looks like below

     1. homepage.html.jsp

     2. homepage.html

     3.homepage.jsp

     4.GET.html.jsp

     5.GET.html

     6.GET.jsp

This is best explained in [SLING-387] Simplify script paths and names - ASF JIRA . Please read and let me know if you have more questions. Adding below few more reads for you

Please read the URL decomposition under https://docs.adobe.com/docs/en/aem/6-3/develop/the-basics.html#URL Decomposition

From the above link

      Hope this helps you .

Thanks

Veena

View solution in original post

5 Replies

Avatar

Community Advisor

I think extension take precedence. So GET.html will execute

Avatar

Level 4

Between jsp and html first priority goes to jsp as by default a component is linked to jsp at the time of creation.

Here you can see a very clear explanation about sling resolution, selector, extension with examples.

http://www.aemcq5tutorials.com/tutorials/sling-resource-resolution-aem/

Avatar

Correct answer by
Community Advisor

Hi Saurabh

      Sling Resolution is an important module in Sling. It is really important to understand the sling resolution before even starting AEM development. I have tried to explain the same here for a similar question here Template component can't override page.html . This explains how the files are resolved.

To answer your question simply,

     if the user request a content as --> <path>.<selector...>.<extension>

     then for the request resolution files ending with <selector>.<extension>.<script extension> takes priority

Always understand that selectors have maximum priority and the more selectors are matched the highest the priority. If selectors are not matched then the extension gets priority.

Here in your case sling priority looks like below

     1. homepage.html.jsp

     2. homepage.html

     3.homepage.jsp

     4.GET.html.jsp

     5.GET.html

     6.GET.jsp

This is best explained in [SLING-387] Simplify script paths and names - ASF JIRA . Please read and let me know if you have more questions. Adding below few more reads for you

Please read the URL decomposition under https://docs.adobe.com/docs/en/aem/6-3/develop/the-basics.html#URL Decomposition

From the above link

      Hope this helps you .

Thanks

Veena

Avatar

Level 10

Hi Saurabh,

See this Adobe's Ask the Community Expert's session(ATCE) session by Lokesh about AEM and Sling.

It was beautifully explained there: ATACE May15 Sling

Hope this helps!

~Ratna.

Avatar

Level 2

HTML will be preferred over JSP .(If they have same file name) Also extension should not be confused as while script selection Selcetor + extension will be the best match and it will be given priority .

So if you are trying localhost//resourcePath/selector1.selector2.extension.

Then Script precedence will be

1 - selector1/Slector2.extension

2 - selector1.extension

3- selector1.(HTML/JSP/ESP/JSON)

4- extension.(HTML/JSP/ESP/JSON)

5- NodeName.(HTML/JSP/ESP/JSON)

6- ResquestType(GET/HEAD).(HTML/JSP/ESP/JSON)

You can Watch This video and provide your valuable input Sling Script Resolution - YouTube