UseCase: – I had a situation in which needed to return custom information corresponding to every page in AEM and also use it via component to display to end user .
-Then i have to invoke a Servlet on every page and with the use of selector want to return some information in JSON Format which can be used to display via Component on a Page to end user .
Solution : -For such situations we use the resourceType as cq/Page for registering Servlet , so that Servlet is registered for every Page.
– Then with the use of a particular selector we can get results like list information/required custom information for every AEM page and display either via component with its ajax request has a url of Current Page.Selector which invokes the Servlet and renders result .
Note: – Just for reference Sling resolves on basis of Primary Type example cq:Page for Page and dam:Asset for Dam in case sling:resourceType is missing .