Jsp download file size
We start tomcat and we create PDFs on the fly. I don't have the file size in front of my hand, so I cannot directly link to the file on the server. So I am sending the output directly.
response.setContentType("application/force-download");
OutputStream o = response.getOutputStream();
And then I directly output to that OutputStream.
The only problem is that the recipient doesn't get the file size, so they don't know how long the download will take. Is there a way to tell the answer how big the file is?
EDIT I know the size of the file, I just can't tell STREAM how big the file is.
0
source to share
4 answers
The response object must have a setContentLength method :
// Assumes response is a ServletResponse
response.setContentLength(sizeHere);
+5
source to share