Custom repsonse header set in JSP not set via Dispatcher | Community
Skip to main content
daitienshi
Level 2
November 29, 2016
Solved

Custom repsonse header set in JSP not set via Dispatcher

  • November 29, 2016
  • 7 replies
  • 4561 views

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!

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

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.

7 replies

Jitendra_S_Toma
Level 10
November 29, 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!

 

Feike_Visser1
Adobe Employee
Adobe Employee
November 29, 2016

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

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

daitienshi
Level 2
November 29, 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!

daitienshi
Level 2
November 29, 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.

 

Feike_Visser1
Adobe Employee
Adobe Employee
November 29, 2016

Only response headers.

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
November 29, 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.

April 6, 2020
This solution does not work.
Adobe Employee
September 10, 2021

Did you got the solution ?