http://feeds.feedburner.com/SpendYourTimeHere-Once

Current Affiares

Monday, August 13, 2012

How to make the log off button working in java ?

How to make the log off button working in java ?


import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

public String logoff() {
        ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
        HttpSession session = (HttpSession) ectx.getSession(false);
        session.invalidate();

        return "index?faces-redirect=true";
    }

// using the method with command button of primefaces
<p:commandButton type="submit" icon="ui-icon-power" value="Log-off" immediate="true" 
action="#{user.logoff()}" ajax="false"/>

No comments:

Post a Comment

My Blog List

Popular Posts

All Rights Reserved To SYTHONCE. Ethereal theme. Powered by Blogger.