Tuesday, July 9, 2013

ADF 11G : How to Implement Logout ?

ADF 11G : How to Implement Logout ?

    public String logOut()  throws IOException{
        HttpSession session = null;
          FacesContext fctx = FacesContext.getCurrentInstance();
          ExternalContext ectx = fctx.getExternalContext(); 
          session = (HttpSession)ectx.getSession(false);
          HttpServletResponse response = (HttpServletResponse)ectx.getResponse(); 
              String currentPage = "faces/logout.jspx";
          String url = ectx.getRequestContextPath()+"/adfAuthentication?logout=true&end_url=" + currentPage;     
          try { 
             response.sendRedirect(url); 
              session.invalidate();
        
          } catch (Exception ex) { 
             ex.printStackTrace(); 
          } 
          fctx.responseComplete();
          return null; 
      }