Reputation: 984
I am developing a Java Web Application using JSF 2.0. Users can upload files. I dont want to store files in project folder. I want to store them in another folder. I store path of files in DB. How can I generate links to users to download file.
Upvotes: 0
Views: 539
Reputation: 1109112
That depends on the appserver used. To the point, you need to add that external folder as another document root to the server's deploy configuration, so that it can be accessed by an URL.
In case of for example Tomcat, it's a matter of adding a new <Context>
element to the server.xml
. See for an example also this answer: Load images from outside of webapps / webcontext / deploy folder using <h:graphicImage> or <img> tag. In case of for example Glassfish, it's a matter of adding a new alternatedocroot
property to the glassfish-web.xml
. See for an example also this answer: Uploaded image only available after refreshing the page
Upvotes: 1
Reputation: 240928
You need to create an action method which will read the file from given path and will write it to response,
Also See
Upvotes: 3