serdar
serdar

Reputation: 984

JSF Link to Outer file

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

Answers (2)

BalusC
BalusC

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

Jigar Joshi
Jigar Joshi

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

Related Questions