Monday, September 22, 2014

Get the hostname and context root in managed bean in ADF

    public FacesContext getFacesContext() { 
      return FacesContext.getCurrentInstance(); 
    } 
   
    public ExternalContext getExternalContext() { 
      return getFacesContext().getExternalContext(); 
    }
   
    public void getRequestAPartURL() {
        HttpServletRequest request =
            (HttpServletRequest)getExternalContext().getRequest();

        // Get the current URL
        String requestUrl = request.getRequestURL().toString();

        // Get the context root
        String contextRoot = getExternalContext().getRequestContextPath();
       
       // Get host and port number
       requestUrl = requestUrl.substring(0, requestUrl.indexOf(contextRoot))
    }

No comments:

Post a Comment