0

我对 jasig cas 注销有疑问。当我尝试调用下面的注销方法时,我收到此错误:

HTTP Status 500 - Cannot create a session after the response has been committed. javax.servlet.ServletException: Cannot create a session after the response has been committed

public String logout() {

Logger logger = Logger.getLogger(this.getClass().getName());

    ExternalContext extCtx = FacesContext.getCurrentInstance()
            .getExternalContext();

    HttpServletResponse response = (HttpServletResponse) extCtx
            .getResponse();

    String casLogoutURL = extCtx.getInitParameter("casLogoutURL");

    String serverName = extCtx.getInitParameter("serverName");

    try {

        extCtx.invalidateSession();
        logger.debug("Session Destroyed!");

        response.sendRedirect(casLogoutURL + "?service="
                + URLEncoder.encode(serverName, "UTF-8"));

        logger.debug("Logging out user...");

    } catch (IOException e) {
        logger.error("Impossible execute redirect after logout - CAS URL SERVER UNREACHABLE");
        e.printStackTrace();
    }

    return null;
}

我知道重定向功能不会破坏生命周期,因此调用页面将在返回后处理。我想销毁会话并转到 CAS 注销页面。我该如何解决这个问题?

4

0 回答 0