Expand my Community achievements bar.

SOLVED

sling resource resolver clarification

Avatar

Level 6

Hi Team,

I have created one component called page component and in that there are 4 html files  and 1 jsp file listed below

page.html

first.html

second.html

third.html

JSP page is

testing.jsp

In content i have created one nt:unstructured file called hello-world like below

1814522_pastedImage_0.png

Now if i hit URL like

http://localhost:4502/content/hello-world.html --->page.html is loading

if i hit like  http://localhost:4502/content/hello-world.first.html-->first.html page is loading

sling resolver are like

protocol=http

host=localhost

port=4502

content-path=/content/hello-world

selector=first

extension=html

Like that if i hike http://localhost:4502/content/hello-world.testing.jsp​   i am getting like

1814532_pastedImage_3.png

protocol=http

host=localhost

port=4502

content-path=/content/hello-world

selector=testing

extension=jsp

Sling resolved preference will be given like

1.selector+extension

2.selector

3 extension  etc

Now the Question is  Why url is not resolved for jsp page.

Kindly help for sling resolver for jsp page

Regards

Manikantha R

9844254734

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi Manikantha, If I recall correctly, the default Sling GET Servlet will handle requests with the extension ".html", ".txt", ".json", and ".xml". If you are using a different extension, then another servlet will be needed to handle it or a 404 will be returned. When you request for /content/hello-world.testing.html, the resource resolver will attempt to find if there is a node /content/hello-world. If the node exists, then it will use the appropriate script associated with the node and execute the script. In your request (e.g. /content/hello-world.testing.html), the best match script is the one associated with the selector "testing". Thus, the script "test.jsp" is executed to render the node. Consequently, it is not possible to directly request for the script (e.g. /content/hello-world.testing.jsp).

View solution in original post

5 Replies

Avatar

Employee

Also this is a very good doc to understand Sling request processing:

The Basics

Avatar

Level 6

Hi Arun,

Thanks for your quick response

By  hitting http://localhost:4502/content/hello-world.testing.html

I am  able to open the testing.jsp file.

protocol=http

hostName=localhost

port=4502

content path=hello-world

selector=testing

extension=.html

Now question

1. How it is opening .jsp file if i give the .html as extension.

2.why it is not opening .jsp file as extension

Arun can you   elaborate bit here how it is working.

Regards

Manikantha R

Avatar

Correct answer by
Employee

Hi Manikantha, If I recall correctly, the default Sling GET Servlet will handle requests with the extension ".html", ".txt", ".json", and ".xml". If you are using a different extension, then another servlet will be needed to handle it or a 404 will be returned. When you request for /content/hello-world.testing.html, the resource resolver will attempt to find if there is a node /content/hello-world. If the node exists, then it will use the appropriate script associated with the node and execute the script. In your request (e.g. /content/hello-world.testing.html), the best match script is the one associated with the selector "testing". Thus, the script "test.jsp" is executed to render the node. Consequently, it is not possible to directly request for the script (e.g. /content/hello-world.testing.jsp).

Avatar

Community Advisor

Hi,

The script engines looks for below scripts if you access resource with selector

seletctor.html or

selector.jsp or

selector.esp or

selector.jst

In your case testing.jsp found.



Arun Patidar