public String getUrl(){
ServletContext servletContext = (ServletContext) getFacesContext().getExternalContext().getContext();
ServletRequest request = (ServletRequest) getExternalContext().getRequest();
ServletResponse response =(ServletResponse) getExternalContext().getResponse();
ExternalContextImpl external = new ExternalContextImpl(servletContext, request, response);
return (external.isSecure()?"https":"http")
+"://"+getExternalContext().getRequestServerName()+":"+
getExternalContext().getRequestServerPort()+
getExternalContext().getRequestContextPath();
}