Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Creating a servlet for a component that is not under /content?


Level 7


My goal is to create a token whenever a page is rendered that contains a component called someTeaser. This someTeaser component renders in the template after the content and before the footer and is not editable. It is configured fixed in the template structure.

The problem appears when I want to create a servlet for someTeaser. This component is not in the Content Repository crxde.


resourceTypes = {Constants.ResourceTypes.SOME_TEASER},
selectors = {"token"},
extensions = Constants.Extensions.JSON

 The resource for this component is /conf/xx/settings/wcm/templates/someTemplate/structure/jcr:content/root/main/container/someTeaser. This resource cannot be resolved in publish. It is not under content but rather under conf.


Request URL: https://publish_server/conf/xxx/settings/wcm/templates/someTemplate/structure/jcr:content/root/main/...

Request Method: GET

Status Code: 404 Not Found


An alternative solution would be to use define resourceTypes = {Constants.ResourceTypes.PAGE}  in the servlet but then every page will check if it has the selector token.

Is there a better solution for this?


4 Replies


Community Advisor

Hi @anasustic 


Can you please be more clear on your query? I am not able to understand "This component is not in http://localhost:4506/crx for any detailHelp pages."



Kiran Vedantam.


Level 7

Hi @Kiran_Vedantam yes, of course. I tried to be more clear on the original description.


Employee Advisor

Looks like you are using editable templates in your site.

That means, that at rendering time the content of the template is merged with the content of the actual page (unlike static templates where the template is copied into the location where the resulting page is to be created). That means in the case of editable templates you don't find necessarily find all components below the page resources anymore (when using the repository browser).


So you can request your resource via /content although it's not persisted there in the JCR repository (as node).



Level 7

Thanks @Jörg_Hoh 

I was able to request the token for the container that is avaliable in the JCR repository.


String containerPath =  PathBuilder.with(currentPage.getPath())

 and resolve the container url nicely using