Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

9 replies

MayurSatav
Community Advisor
Community Advisor
Jun 16, 2023 9:22 AM UTC

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.

Translate
Mayur Satav | www.mayursatav.in
Rajarshi306278674zn4
Adobe Employee
Adobe Employee
Jun 22, 2023 4:31 AM UTC

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)

 

 

Translate
kautuk_sahni
Level 9
Nov 4, 2024 7:38 AM UTC

@joerghoh could you please help this user? 

Translate
Kautuk Sahni
TarunKumar
Community Advisor
Community Advisor
Jun 16, 2023 11:00 AM UTC

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?


Translate
Level 2
Sep 29, 2023 12:55 AM UTC

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

Translate
joerghoh
Adobe Employee
Adobe Employee
Nov 6, 2024 5:54 PM UTC

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

Translate
Adobe Employee
Sep 15, 2025 5:48 AM UTC

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();
Translate
joerghoh
Adobe Employee
Adobe Employee
Sep 15, 2025 7:15 AM UTC

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

Translate