Sling Resource Resolution Preference

saurabhp8517704

08-09-2017

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

Accepted Solutions (1)

Accepted Solutions (1)

Veena_Vikram

MVP

09-09-2017

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

Answers (4)

Answers (4)

Gaurav_Tiwari_8

04-12-2018

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

Ratna_Kumar

MVP

10-09-2017

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.

Diego_Fontan

08-09-2017

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/