jMarcel
jMarcel

Reputation: 993

How to Logout in a JSF application

I have to use my Company login resource and, how can I set the logout servlet into my primefaces component?

How "translate" this...

//in a jsp page:
<a href="<%=request.getContextPath()%>/servlet/com.app.ServletEndSession?initialPage=/index.jsp" > Logout </a>

...into this:

<p:commandButton type="button" value="Logout" action="??" />

Thanks in advance.

Upvotes: 0

Views: 748

Answers (2)

kolossus
kolossus

Reputation: 20691

Your <a/> should become

<p:button href="#{facesContext.externalContext.requestContextPath}/servlet/com.app.ServletEndSession?initialPage=/index.jsp" value="Dialogit"/>

Upvotes: 1

VeenarM
VeenarM

Reputation: 1263

You could just use a managed bean on the commandButton and then do a redirect in your page? As you definitely want to navigate away with p:commandbutton youw would want to set ajax="false" put action .

Alternatively you could just use

<p:commandButton type="button" value="logout" onclick="javascriptTolinkToServletEndEsssion" />

Upvotes: 0

Related Questions