Convert Path to Resourcetype | Community
Skip to main content
Level 3
June 20, 2025
Question

Convert Path to Resourcetype

  • June 20, 2025
  • 2 replies
  • 347 views

Hi All , 

 

I have a servlet ajax call in my JS file using path type  and this JS file is not part of any component but a theme clientlibrary used for one of our child website.

 

I want to convert that servlet path type to resourceType for cloud.

 

How is the best approach to handle such Servlets and how we can convert to resourcetype.

2 replies

Karishma_begumSh
Level 4
June 20, 2025

Hi @sb2512 

Change the servlet from path to resource type

@SlingServlet(resourceTypes = "myproject/components/structure/ajaxhandler", extensions = "json")

Create Synthetic Resource

In CRXDE or content structure (e.g. /conf or /content):

/conf/mysite/servlets/ajaxhandler - sling:resourceType = myproject/components/structure/ajaxhandler

Update JavaScript Call

fetch('/conf/mysite/servlets/ajaxhandler.json')

 

Hope this may helpful.

 

Regards,

Karishma.

Sb2512Author
Level 3
June 20, 2025

Hi @karishma_begumsh ,

 

Thanks for the reply.

 

Is there any documentation/example for this.

Also keeping this in /conf or /content which is mutable is recommended ?

 

kautuk_sahni
Community Manager
Community Manager
September 2, 2025

@sb2512 just checking in! Were you able to get this resolved? If one of the replies above helped—whether it completely solved the issue or simply pointed you in the right direction—marking it as accepted can make it much easier for others with the same question to find a solution. And if you found a different way to fix it, sharing your approach would be a great contribution to the community. Your follow-up not only helps close the loop but also ensures others benefit from your experience. Thanks so much for being part of the conversation!

Kautuk Sahni