Get JSP output within Servlet in AEM | AEM Community Blog Seeding

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

26-05-2020

BlogImage.jpg

Get JSP output within Servlet in AEM by howtoaem Blog

Abstract

Get JSP output within Servlet in AEM
In CQ, we need to process jsp within servlet then combine the result with other results 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 jsp.

RequestDispatcher dispatcher = request.getRequestDispatcher(resource);
dispatcher.forward(request, response);
We tried using mock response 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 issues.

Read Full Blog

Get JSP output within Servlet in AEM

Q&A

Please use this thread to ask the related questions.