Set respone header in Sightly | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

You would have to this via Java/Javascript use-api call.

There you can do something like getResponse().setHeader("a", "b");

3 replies

smacdonald2008
Level 10
October 16, 2015

What use case you are trying to so with Sighty? If you want to set a header and return data in a HTTP response where you need to set a Header, why not use an AEM Sling Servlet? 

Level 2
October 16, 2015

Hi,

I am using a Sling Servlet talking to Solr to get search results. Then the Servlet is using a RequestDispatcher to forward to the page rendering the search results.

I tried to set a Cache-Control header in the Servlet but it does not make it thru when using "forward" on the RequestDispatcher. Therefore I was thinking about adding the header in the Sightly template. Now I have seen that when I use "include" on the RequestDispatcher the request header is set.

Best,

Ronald

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

You would have to this via Java/Javascript use-api call.

There you can do something like getResponse().setHeader("a", "b");