Is there a way to programmatically render a Sling resource?

Avatar

Avatar
Validate 100
Level 4
LinearGradient
Level 4

Likes

22 likes

Total Posts

208 posts

Correct reply

1 solution
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 4
LinearGradient
Level 4

Likes

22 likes

Total Posts

208 posts

Correct reply

1 solution
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
LinearGradient
Level 4

15-10-2015

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.

View Entire Topic

Avatar

Avatar
Boost 5
Employee
kalyanar
Employee

Likes

5 likes

Total Posts

182 posts

Correct reply

78 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 50
Affirm 5
View profile

Avatar
Boost 5
Employee
kalyanar
Employee

Likes

5 likes

Total Posts

182 posts

Correct reply

78 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 50
Affirm 5
View profile
kalyanar
Employee

15-10-2015

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