Setting headers on redirected external URL

2019-09-03 13:59发布

问题:

Is it possible that a jsf application can navigate to an external link and specify headers for that external link? So far I have tried to call in the backing bean method:

ExternalContext#setResponseHeader(java.lang.String name, java.lang.String value)
ExternalContext#redirect(java.lang.String url) 

The redicection is successfully executed but the Headers are lost. Is there any way to specify a link accompanied with the headers?

回答1:

No, HTTP doesn't allow setting headers on a different request.

The headers have to be set by the code behind the target URL. Whatever problem you incorrectly thought to solve this way has definitely to be solved differently.