This is my Strut file.
I have solved this question. I have stored the physical path of the file in the data base.For example if your project path is : D:/Workspace_ABC/SampleProject/WebContent/D-Files/APJ.AbdulKalam.pdf then store this path as it is in the database table. and then use this path to download file.
The problem with
String path2=request.getParameter("path1");
This method may return null
if parameter path1
is missing. If it's not null
then it should be a valid path to the readable file that you application has access.
Read the example How to read file in Java – FileInputStream. You can trace the output with the code.
System.out.println("Total file size to read (in bytes) : "
+ getFileInputStream().available());
The getter is needed to return a stream
result, and as you are using dynamic parameter in the result config. You should provide the getter for fileName
.