Do we have any substitute for com.day.cq.contentsync.handler.util.RequestResponseFactory , this is deprecated ? | Community
Skip to main content
June 16, 2023
Question

Do we have any substitute for com.day.cq.contentsync.handler.util.RequestResponseFactory , this is deprecated ?

  • June 16, 2023
  • 5 replies
  • 2453 views
No text available

5 replies

MayurSatav
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 16, 2023

Hi @kjj ,

Yes, the com.day.cq.contentsync.handler.util.RequestResponseFactory class is deprecated in AEM. The recommended substitute for this class is to use the org.apache.sling.api.request.RequestResponseFactory interface instead. To obtain an instance of the RequestResponseFactory interface, you can use the org.apache.sling.api.SlingHttpServletRequest object.

Rajarshi306278674zn4
Adobe Employee
Adobe Employee
June 22, 2023

Hey @mayursatav can you just recheck or tell me how you found the api, i cannot find it, giving a snap from IDE, share me also the java-doc link for the same (org.apache.sling.api.request.RequestResponseFactor)

 

 

kautuk_sahni
Community Manager
Community Manager
November 4, 2024

@joerghoh could you please help this user? 

Kautuk Sahni
TarunKumar
Community Advisor
Community Advisor
June 16, 2023

Hi @kjj 

What is the reason you are using "RequestResponseFactory" API, I suggest if it is just to create request , you can get it directly from SlingHttpServletRequest.
Let me know if you have any other specific reason?


Level 2
September 29, 2023

my reason for using it is to get the generated html for my component, 

 

the above person Mayur say use SlingHttpServletRequest request to get the RequestResponseFactory, how can that be done? i cant find any method in SlingHttpServletRequest that return the RequestResponseFactory

joerghoh
Adobe Employee
Adobe Employee
November 6, 2024

Check https://sling.apache.org/documentation/bundles/servlet-helpers.html, it explains the tools Sling provides for this.

Adobe Employee
September 15, 2025

https://sling.apache.org/documentation/bundles/servlet-helpers.html#internalrequest-helpers is not production safe instead use SlingRequestProcessor.

 

.... import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.request.builder.Builders; import org.apache.sling.api.request.builder.SlingHttpServletResponseResult; import org.apache.sling.engine.SlingRequestProcessor; .... /** The sling processor. */ @Reference private SlingRequestProcessor slingProcessor; ..... SlingHttpServletRequest slingRequest = Builders.newRequestBuilder(targetResource) .withExtension("html") .withSelectors("test") .withParameter("wcmmode", "disabled") .withRequestMethod("GET").build(); SlingHttpServletResponseResult responseResult = Builders.newResponseBuilder().build(); // Process the request slingProcessor.processRequest(slingRequest, responseResult, resolver); String res = responseResult.getOutputAsString();
joerghoh
Adobe Employee
Adobe Employee
September 15, 2025

And just as a general statement: AEM making requests to itself is in general considered a code smell. There should always be a direct way (using API) to achieve the same.

 

(And it case it is not, there should be one... please raise a feature request for it.)