I have a template with the Logout Link of name "Cerrar Sesión"
<div id="top">
<ui:insert name="top">
<h:form>
<h:commandLink value="Cerrar Sesión" action="#{loginBean.cerrarSesion}" />
</h:form>
</ui:insert>
</div>
My Bean has the cerrarSesion
function:
public void cerrarSesion() throws IOException {
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.invalidateSession();
ec.redirect("../view/index.xhtml?faces-redirect=true");
}
The Project URL is: http://192.168.1.72:8083/PROJECT/
My problem is if I click on "Cerrar Sesión", the URL changes to http://192.168.1.72:8083/PROJECT/faces/view/inicio.xhtml, the same page where I was (it refreshes).
When I clicked on "Cerrar Sesión" again, the program redirects correctly: http://192.168.1.72:8083/PROJECT/faces/view/index.xhtml
I am using JSF with PrimeFaces, NetBeans, and GlassFish.