Issue
For a web application built on struts and jsp technologies, I'm looking for a good example which explains how to download files from the server side.
Solution
i manage to do it with this few lines of code : just add this to your action :
OutputStream out = response.getOutputStream();
response.setContentType("application/rtf");
FileInputStream in = new FileInputStream("your_file_path");
byte[] buffer = new byte[4096];
int length;
while ((length = in.read(buffer)) > 0){
out.write(buffer, 0, length);
}
in.close();
out.flush();
Answered By - fatiDev
Answer Checked By - Gilberto Lyons (JavaFixing Admin)