Navigate to external URL from a backing bean?

£可爱£侵袭症+ 提交于 2019-11-30 22:01:18

You can create a page logout.xhtml, so the code will look like this:

public String getLogoutUrl() {
    return "/logout.jsf";
}

and in the page add:

<META HTTP-EQUIV="Refresh" CONTENT="0;URL=https://localhost:8080/anotherwebapp/logout.html">

You can also just use ExternalContext#redirect().

public void logout() throws ServletException, IOException {
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    ((HttpServletRequest) ec.getRequest()).logout();
    ec.invalidateSession();
    ec.redirect("http://example.com/anothercontext/logout");
}

No need for an intermediating page with a meta refresh.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!