Best way to get XML response of servlet in custom URL | Community
Skip to main content
Level 2
Jul 26, 2022 1:02 PM UTC
Solved

Best way to get XML response of servlet in custom URL

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Shashi_Mulugu
Shashi_MuluguAccepted solution
New Participant
Jul 26, 2022 2:11 PM UTC

@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.

 

2 replies

Nikhil_Verma
Level 4
Jul 27, 2022 12:01 AM UTC

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-via-resource-type/td-p/404215

Translate
Shashi_Mulugu
Shashi_MuluguAccepted solution
New Participant
Jul 26, 2022 2:11 PM UTC

@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.

 

Translate