I’m using Java with JSF an Glassfish 3 container.
In my web application I’m trying to implement a file(image) management system.
I have a config.properties file from where I read the path where the uploaded images should be saved.
save.file.path.event = D:\\upload
The file upload works and all the files are in their place but when I try to list the image the browser says that no image could be found.
<img src = "D:/upload/img1.png" />
The web server is in a totally different partition.
Besides the no image found problem I have the following question regarding good practices in this area: If their will be a time when I will publish the application on a web server how safe / correct is to use a path like D:\\upload? Some issues which come to my mind are the differences between operating systems or the uncertainty of a partition name.
It seems that there are two ways to solve this problem
1. Place the files in the Application
If the application name is
MyApplication, you can specify a path likeMyApplication/uploads/ imagesand the files will be saved inside the actual application. The downside of this method is that at every redeploy or hotdeploy the files will be deleted.2. Place an absolute path in the web container config
For Tomcat go to:
../ Apache Tomcat x.x.xx/conf/server.xmland there write:For Glassfish go to:
sun-web.xmlfile and write: