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

Custom repsonse header set in JSP not set via Dispatcher

Avatar

Level 2

I am trying to set a custom response header in my jsp via:

<% response.setHeader("my-custom-header", "custom-value"); %>

When I access the page directly through the Publisher, I can see the header being set.  However, when I hit the same page through the Dispatcher, the header is not there.

I checked the dispatcher.any file and the /clientheaders property is set to "*" to let all headers through.

Would any one know why the header is not present when accessing through the Dispatcher?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Employee

What you can do is to not cache that particular page, then the response headers will come through.

Otherwise the new option to cache the response header is the way to go.

View solution in original post

8 Replies

Avatar

Level 9

Hi,

if you want a custom header to be passed in every request comes to AEM instance, then do the follow steps

  1. configure /clientheaders correctly and remove * as default headers because default headers does not know about your custom headers.
  2. Add you header the way other headers are added.

for more details, follow this link https://docs.adobe.com/docs/en/dispatcher/disp-config.html#par_114_12_0005

If you want every http request to have your custom header even to request is not being served from AEM publish server then you need to do the configuration at the web server level.

Hope this helps. Let me know if you get this things resolved.

daitienshi wrote...

I am trying to set a custom response header in my jsp via:

  1. <% response.setHeader("my-custom-header", "custom-value"); %>

When I access the page directly through the Publisher, I can see the header being set.  However, when I hit the same page through the Dispatcher, the header is not there.

I checked the dispatcher.any file and the /clientheaders property is set to "*" to let all headers through.

Would any one know why the header is not present when accessing through the Dispatcher?

Thanks!

 

Avatar

Employee

By default headers won't be cached by the dispatcher.

You can configure this via the /headers section inside the cache configuration.

Avatar

Level 2

Thanks!

However, we only need this custom response header on a particular page and it seems like overkill to have to enter all possible default headers and then this one custom one under /clientheaders.  Also, my understanding is that the /clientheaders is for allowing which request headers to allow through, whereas I'm looking to get a custom response header through the dispatcher.

Thoughts?

Thanks again!

Avatar

Level 2

Does this apply to both request and response headers?

Feike Visser wrote...

By default headers won't be cached by the dispatcher.

You can configure this via the /headers section inside the cache configuration.

 

Avatar

Correct answer by
Employee

What you can do is to not cache that particular page, then the response headers will come through.

Otherwise the new option to cache the response header is the way to go.