AEM -sling servlet JSON extension

Avatar

Avatar
Validate 1
Level 2
sundarig9086821
Level 2

Likes

10 likes

Total Posts

28 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
sundarig9086821
Level 2

Likes

10 likes

Total Posts

28 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
sundarig9086821
Level 2

22-07-2019

Hi,

We have created a servlet with extension as JS or html.

@SlingServlet(resourceTypes = "project/components/sample", selectors = "sample",

    extensions = "js", methods = "GET")

Resource type is template resource type.

Hence if we access the servlet via /content/project/en.sample.js the servlet responds as expected.

The same works for /content/project/en.sample.html

If we change the extension to JSON the servlet is accessible only when we access  /content/project/en/_jcr_content.sample.json

What is the cause of it to look from jcr:content instead of page path( /content/project/en)?

What can be done if we need to access the servlet as /content/project/en.sample.json

Thanks in advance!!

arunpatidar26, Ratna Kumar, smacdonald2008

JaideepBrar

Kindly help on this..

Thanks,
Sundari.

View Entire Topic

Avatar

Avatar
Validate 1
Level 2
sundarig9086821
Level 2

Likes

10 likes

Total Posts

28 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
sundarig9086821
Level 2

Likes

10 likes

Total Posts

28 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
sundarig9086821
Level 2

23-07-2019

Hi @joerg,

Thanks for the reply.

If that's the case, how does the below snippet works:

@SlingServlet(resourceTypes = "project/components/sample", selectors = "sample",

    extensions = "js", methods = "GET")

@SlingServlet(resourceTypes = "project/components/sample", selectors = "sample",

    extensions = "html", methods = "GET")

Here also if i access /content/project/en the resourceType is not /project/components/sample.. It looks for resource from jcr:content and works fine on hitting /content/project/en.sample.js or /content/project/en.sample.html

Thanks,

Sundari.