what is the best alternative RequestResponseFactory as its deprecated
In the below code there is use of RequestResponseFactory to generate the Html output, I would like to refactor the code as its deprecated now.
also HttpServletRequest httpRequest passed to this method its also using requestResponseFacotry in the servlet who call the below method:
HttpServletRequest httpRequest = requestResponseFacotry.createRequest(HttpConstants.METHOD_GET, url);
public static String fetchHtmlContent(HttpServletRequest httpRequest, ResourceResolver resolver,
RequestResponseFactory requestResponseFactory, SlingRequestProcessor requestProcessor) {
String htmlContentAsString = null;
WCMMode.DISABLED.toRequest(httpRequest);
try (ByteArrayOutputStream htmlByteArrayOutputStream = new ByteArrayOutputStream(); ) {
HttpServletResponse response = requestResponseFactory.createResponse(htmlByteArrayOutputStream);
requestProcessor.processRequest(httpRequest, response, resolver);
response.getWriter().flush();
htmlContent = htmlByteArrayOutputStream.toString(UTF_8);
}
catch (ServletException | IOException e) {
LOG.error("not able not generate HTML content '{}' ", e.getMessage());
}
return htmlContentAsString;
}
currently i'm facing challenge to replace RequestResponseFactory.
Could anyone had face this challenge or any solution without changing solution?