Olá pessoal estou fazendo dois projetos JSF diferentes um para administração e um outro em que preciso utilizar a mesma base de dados para pegar essas imagens e visualizar no outro. O problema é que não sei como resgatar essas imagens sendo que elas são criadas dentro da pasta build do projeto admin. Estou utiliziando um richupload com um lisetner que pega o caminho real do arquivo dessa forma:
public void listenerFoto(UploadEvent event) throws Exception {
FacesContext fc = FacesContext.getCurrentInstance();
ServletContext sc = (ServletContext) fc.getExternalContext().getContext();
String realTargetPath = sc.getRealPath("/fotos/noticias/");
System.out.println("RealtargetPath: " + realTargetPath);
UploadItem item = event.getUploadItem();
String filePathName = "/" + usuarioLogado.getPkMatricula() + "_" + new Date().getTime() + "_" + item.getFileName();
FileInputStream fis = new FileInputStream(item.getFile());
System.out.println("FilePathName: " + filePathName);
Foto foto = new Foto();
foto.setNome(item.getFileName());
foto.setCaminhoFoto(filePathName);
listaFotos.add(foto);
//String fileName = "";
FileOutputStream out = new FileOutputStream(realTargetPath + filePathName);
int bytes = 0;
byte[] bteFile = new byte[1024];
while ((bytes = fis.read(bteFile)) != -1) {
out.write(bteFile, 0, bytes);
}
}
Ele cria um arquivo de imagem na pasta :
/sistemas/portalRSNTI/portalAdmin/build/web/fotos/arquivo.jpg
e eu prevido resgartar ela no projeto :
/sistemas/portalRSNTI/portalSite/
Como faço para pegar a pasta raiz do tomcat “/sistemas/portalRSNTI” para poder visualizar esses arquivos?
Abraço e agradeço desde já a ajuda.