In CQ, we need to process jsp inside the servlet, and then combine the result with the other results that we get from the server before writing back to the browser.
The following code is almost what we need, except that it writes the result back to the browser after processing the jsp.
RequestDispatcher dispatcher = request.getRequestDispatcher(resource);
dispatcher.forward(request, response);
We tried to use a mock answer as follows:
RequestData requestData = new RequestData(slingRequestProcessor, request, mockResponse);
SlingHttpServletRequest slingRequest = requestData.getSlingRequest();
SlingHttpServletResponse slingResponse = requestData.getSlingResponse();
RequestDispatcher dispatcher = request.getRequestDispatcher(resource);
dispatcher.forward(slingRequest, slingResponse);
but we get problems.
source
share