Show image in Java from project directory

3

I'm doing a web project with JSF and PrimeFaces. When I save an image in the directory of my project and I want to use it at that moment, eclipse shows me this error saying that it does not find the specified route:

I have to update the fotosEmpleados folder where I save my photos, right click on the folder and refresh and it is when the image I saved appears as shown in the following image:

When I click on my show button, it saves the image in the mentioned directory, but I also want to show it from the directory and that's where I get an error that says it does not find the specified route. I have to refresh the folder again so that I can recognize that the image exists.

    
asked by ProgramadorJava 01.07.2016 в 19:29
source

1 answer

2

Your problem is not an application but Eclipse. Eclipse does not automatically recognize if files or folders have been created within the project that have not been created by the IDE, unlike a directory browser in an operating system (the classic My Windows PC, for example). Not only does this happen, another similar case is when you update your local repository with server changes (svn update , git pull , mercurial pull and update ) and bring new files, Eclipse does not recognize them either and You have to refresh the folders or the entire project to detect these new files. Therefore, in Eclipse, it is necessary to refresh the folder where the new files have been placed.

In addition to this, the best thing in the design of Web applications is not to save the uploaded files in a folder related to the application. It is better to create a folder outside the context of the web application (perhaps in /opt/ruta/para/imagenes/de/webapp or another) and have a better management of these resources.

    
answered by 02.07.2016 в 19:08