Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Set respone header in Sightly

Avatar

Level 2

Hi,

when using Sightly how can I set a response header?

Thanks and best,

Ronald

1 Accepted Solution

Avatar

Correct answer by
Employee

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

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

View solution in original post

3 Replies

Avatar

Level 10

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? 

Avatar

Level 2

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

Avatar

Correct answer by
Employee

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

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