I am registering a Sling Servlet using
@Component(service=Servlet.class,
property={
Constants.SERVICE_DESCRIPTION + "=Simple Demo Servlet",
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.resourceTypes="+ "myapp/components/structure/page",
"sling.servlet.extensions=" + "json",
"sling.servlet.selectors=" + "myselector"
})
But when calling URL <host:port>/content/myapp/en.myselector.js I get error
Invalid recursion selector value 'myselector'
Cannot serve request to /content/myapp/en.myselector.json in
org.apache.sling.servlets.get.DefaultGetServlet
If we remove "sling.servlet.extensions=" + "json", from annotation, we are able to hit the servlet using <host:port>/content/myapp/en.myselector.js or <host:port>/content/myapp/en.myselector.html but not <host:port>/content/myapp/en.myselector.json
Any additional configurations required? or its conflicting with DefaultGetServlet? We were trying to expose JSON out of resource using servlet and JSON extension semantically making sense.
<host:port>/content/myapp/en/_jcr_content.myselector.json. Since you are registering the servlet against the resource, the resource type for the page would in thejcr:contentnode and not on the page node itself. - rakhi4110jcr:content. I think when both selector and extension is there path tilljcr:contentis required, else if only selector is there it works withoutjcr:contentfor.jsof.html. You can post answer, I can accept it. - Sandeep Kumar