Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Is there a way to programmatically render a Sling resource?

LinearGradient
Level 7
Level 7

Hi,

Apart from rendering Sling resource in response to HTTP requests, is there a way to render them programatically:

protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { String output = // render "/content/foo/bar/baz.html" response.send(...); }

I am looking for an out-of-the-box solution, otherwise using an HTTP Client library it might be possible to do.

Thanks.

1 Accepted Solution
kalyanar
Correct answer by
Employee
Employee

You can do this using SlingRequestProcessorService. Please search for this in junit cases in sling. You will find a lot of examples.

View solution in original post

1 Reply
kalyanar
Correct answer by
Employee
Employee

You can do this using SlingRequestProcessorService. Please search for this in junit cases in sling. You will find a lot of examples.

View solution in original post