I have this problem.
I use spring and I store the attached file (doc,pdf,png…) into the server file system.
Then I save the path and name of the file into my db.
Now how can I read this file as a link into the browser?
I thought to write the file into a web position and give this location to the browser.
is it a good practice?
But how can I delete the file after visualization?
I hope the question is clear.

to write I use:
/** what write for reach temp-file folder (my project name is intranet)
I thougth TEMP_FOLDER=""/intranet/resources/temp-files/";
but It doesnt work. ioexception (The system cannot find the path specified)
*/
final static String TEMP_FOLDER=?????
public static String createTempFile(String originalPathFile,String fileName){
String tempPathFile="";
try {
InputStream inputStream = new FileInputStream(originalPathFile);
tempPathFile=TEMP_FOLDER+fileName;
File tempFile = new File(tempPathFile);
OutputStream out = new FileOutputStream(tempFile);
int read = 0;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.flush();
out.close();
} catch (IOException ioe) {
System.out.println("Error while Creating File in Java" + ioe);
}
return tempPathFile;
}
Place the following link in your JSP
In your controller: