What would be the most efficient way to retrieve a page's content/parsys rendered as html for a sling servlet? Supposing the user calls this servlet with a page path and the servlet just returns the html generated from the parsys on that page. Similar to how the <cq:include> tag works on the jsp side.
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
you can make an httpclient call with getmethod by setting the URL like "http://host:port/pagepath/jcr:content/parsys.html". So that it will return the html content of the parsys. Make sure you add the content type to the getmethod header before executing.
the response will be in html. So you can do what ever you want.
Thanks
Vikram.
Views
Replies
Total Likes
I found a similar question elsewhere and the answer said this is how cq:include is working -
request.getRequestDispatcher("page/path.html").include(request, response);
It's close to what i was looking for but really i just wanted to store the html into a variable and manipulate it instead of directly injecting it into the response stream.
Views
Replies
Total Likes
Hi,
you can make an httpclient call with getmethod by setting the URL like "http://host:port/pagepath/jcr:content/parsys.html". So that it will return the html content of the parsys. Make sure you add the content type to the getmethod header before executing.
the response will be in html. So you can do what ever you want.
Thanks
Vikram.
Views
Replies
Total Likes
Try out SlingRequestProcessor class:
@Reference SlingRequestProcessor slingRequestProcessor; slingRequestProcessor.processRequest(HttpServletRequest request, HttpServletResponse response, ResourceResolver resourceResolver)
You need to create mock request and response objects. You might want to have a look at RequestResponseFactory
Views
Replies
Total Likes