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 that I did.
@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 it in my JSP like this:
<img src="<c:url value='/imagem/formaPagamento?id=${f.id }'/>">
In my controller I use an annotation to define as an image.
@Controller
@Path("/imagem")
public class ImagemController {
The @Open annotation is one that I created to let the code be accessed without having to be logged into the system, so disregard.
I really do not know if it helps, but maybe you're doing something different. These are parts of my code working, step by step. There in Filename, it's a class that has constants that take my folders from the server. So I find it quieter to work on and make future path modifications, rather than crashing into the source code. Of course this goes from programmer to programmer.
I also had a lot of trouble finding my images in the folder .... Generally the JSP call was correct and only my file was not found because I was using linux. I did in the case a simple main class, trying to find this file and returning a (FileNotFoundException) until I found the correct way to find my image. Yes, I did the routine for the JSP. So I think it's easier to test without having to run on the server.
I do not know if I helped you, but my contribution is still there.