How to set custom HTTP header while redirecting URL in JSF 1.1?

1k Views Asked by At

Our application developed using JSF 1.1 framework. While enabling service provider based SSO, we need to post SAML request data with HTTP header while redirecting to IDP URL. How to set custom HTTP header value while redirecting to IDP URL in JSF 1.1 ?

1

There are 1 best solutions below

1
On

I'm not sure about JSF 1.1 considering that it's severely outdated. Consider updating to 2.0 or 2.2 at least. However, you might be able to have redirect occur through a managed bean action, and set headers just before a redirect.

ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response =  (HttpServletResponse)context.getResponse();
response.setHeader("Custom-Header", "test");
externalContext.redirect("foo.xhtml");

Source: https://richhewlett.com/2015/03/02/setting-http-headers-in-java-server-faces-jsf/ https://docs.oracle.com/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.2/docs/api/ (Couldn't find 1.1 docs)