Good afternoon Darlan Oliveira, I’m new here, but I think I can help you. In my project I made a Controller to manage my images and this is a code I made.
@Open
@Get
@Path("/formaPagamento")
public Download imagemFormaPagamento(String id) {
File file = new File(NomenclaturaArquivo.getImagemFormaPagamento() + id);
String contentType = "image/png";
String filename = id + ".png";
try {
return new FileDownload(file, contentType, filename);
} catch (FileNotFoundException e) {
System.out.println("erro: " + e);
return null;
}
}
And I call her on my JSP like this:
<img src="<c:url value='/imagem/formaPagamento?id=${f.id }'/>">
and in my controller I use an annotation to define as image.
@Controller
@Path("/imagem")
public class ImagemController {
The @Open annotation is one I created to let the code be accessed without having to be logged in to the system, so disregard.
I don’t really know if it helps you, but maybe you’re doing something different. These are parts of my code working, step by step. There in the Filename, it is a class that has constants that take my folders from the server. So I find it easier to work and to make future modifications of paths, instead of failing the source code. Of course this goes from programmer to programmer.
I also had enough problems to find my images in the folder.... Usually the JSP call was correct and only my file was not found as it was using linux. I did in the case a main simple class, trying to find this file and returning one (Filenotfoundexception) until finding the correct way to find my image. Oh yes I passed the routine to JSP. So I think it’s easier to test without running on the server.
I don’t know if I helped you, but here’s my contribution.