Expand my Community achievements bar.

SOLVED

Best way to get XML response of servlet in custom URL

Avatar

Level 2

Hi,

I've got a servlet that returns an XML in response. Have control over registering servlet as path or resource based.

Now when I hit a custom URL like "www.sitename.com/abc/releases/result.xml"(not an existing page), the servlet should trigger and dump the XML response.

 

Approach 1: Use the logic of AEM sitemap.xml and achieve this with custom etc resource mapping and URL rewrite.

 

Any other best approaches?

 

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@VinayHegde It depends on the complexity of the business logic and frequency of date to be updated in that xml.

 

  • If it is too heavy execution and content is not too dynamic, i would prefer to run the logic offline maybe as scheduler once in a day and store the xml as physical asset in DAM path and i would point my dispatcher/rewrite rules to point to DAM location based on the public url you want to have.
  • If the content is dynamic in nature changes as and when requested, say price related etc.. no other option but to go with a servlet and execute logic at runtime.

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@VinayHegde It depends on the complexity of the business logic and frequency of date to be updated in that xml.

 

  • If it is too heavy execution and content is not too dynamic, i would prefer to run the logic offline maybe as scheduler once in a day and store the xml as physical asset in DAM path and i would point my dispatcher/rewrite rules to point to DAM location based on the public url you want to have.
  • If the content is dynamic in nature changes as and when requested, say price related etc.. no other option but to go with a servlet and execute logic at runtime.

 

Avatar

Level 5

Agree with @Shashi_Mulugu .

If the XML is dynamic then you can follow the below steps to creating a custom servlet:

Create a custom servlet registered by resource type (recommended): https://aem.redquark.org/2019/07/sling-servlet-04-registration-via.html
For more understanding of how servlet by resource type works: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-configure-a-servlet...