0

I use a (Primefaces 3.5) logout button in my application that looks like:

<p:commandButton ajax="false" value="Logout" action="#{loginBean.logout}" />

The bean method looks like:

public String logout() {
    ExternalContext externalContext =
            FacesContext.getCurrentInstance().getExternalContext();
    HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
    try {
        request.logout();
        System.out.println("Logging out!");
        return "/mylogin?faces-redirect=true";
    } catch (ServletException ex) {
        System.out.println("Failed to logout!");
        return null;
    }      
}

The string Logging out! is printed correctly, but the redirect is not performed!

Only when I click the logout button a second time the login page is displayed again?

Why?

Regards, G.Verhaag

g.verhaag
  • 139
  • 3
  • 11

1 Answers1

0

Change the return statement to

return "mylogin?faces-redirect=true."

Get rid of the slash.

Sekhon
  • 108
  • 1
  • 10