Queridos já tentei de tudo.
Uso jsf e primeface.
com isso
FacesContext aFacesContext = FacesContext.getCurrentInstance(); ServletContext context = (ServletContext) aFacesContext.getExternalContext().getContext(); ServletContext servletContext = (ServletContext) FacesContext .getCurrentInstance().getExternalContext().getContext(); String realPath= FacesContext.getCurrentInstance().getExternalContext().getRealPath("/"); // String realPath = servletContext.getRealPath("/");
String caminho = realPath + "..\\arquivos\\imagens\\"; System.out.println(caminho); this.setPath(caminho+usuario.getImagem());
Gera esse erro no console do navegador
Not allowed to load local resource: file:///C:/Users/adm/workspace/.metadata/.plugins/org.eclipse.wst.server.co…s/imagens/foto.gif?pfdrid_c=false&uid=a87eb15b-58f9-4c24-ad4b-901e32af7548
se clico nesse caminho a imagem abre normalmente
valeu, abraço, agradeço a ajuda.