I need to save a file and download file in directory outside server context. I am using Apache Tomacat I am able to do this in directory present in webapps directory of application
If my directory structure is as follows,
--src --WebContent -- uploaddir -- myfile.txt Then I am able to download in by simply.
<a href="uploaddir/myfile.txt" target="_blank">download</a> But, problem is when file is in some other directory say d:\\uploadedfile\\myfile.txt
then I wont be able to download it, as resource is not in server context as above.
I have file path to uuid mapping, like,
d:\\uploadedfiles\\myfile.txt <-> some_uuid
then I want file should be downloaded, on click of following,
<a href="filedownloadservlet?ref_file=some_uuid">download</a> So, How to make file downloadable when it is outside the server context, I heard about getResourceAsStream() method which would do this , But would any one help me on how to do this, probably with simple code snippet?