Custom repsonse header set in JSP not set via Dispatcher

Avatar

Avatar

daitienshi

Avatar

daitienshi

daitienshi

28-11-2016

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!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

29-11-2016

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.

Answers (5)

Answers (5)

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

29-11-2016

Only response headers.

Avatar

Avatar

daitienshi

Avatar

daitienshi

daitienshi

29-11-2016

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

Avatar

daitienshi

Avatar

daitienshi

daitienshi

29-11-2016

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

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

29-11-2016

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

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

Avatar

Avatar

Jitendra_S_Toma

Avatar

Jitendra_S_Toma

Jitendra_S_Toma

28-11-2016

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!