Olá
Pessoal
Preciso fazer download de um arquivo no meu servidor, alguem teria uma action com uma rotina de download para me enviar?
Grato
Olá
Pessoal
Preciso fazer download de um arquivo no meu servidor, alguem teria uma action com uma rotina de download para me enviar?
Grato
try {
String relatorio = gerarRelatorio();
String nome = codigo + ".txt";
FileOutputStream fileOut = new FileOutputStream(nome);
fileOut.write(relatorio.getBytes());
fileOut.flush();
fileOut.close();
response.setContentType("inline/download");
String arq = "attachment;filename=" + nome;
response.setHeader("Content-Disposition", arq);
ServletOutputStream os = response.getOutputStream();
os.write(relatorio.getBytes());
os.flush();
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Blz? Flw! :thumbup:
Escreva o stream do arquivo no response (como nosso amigo acima escreveu) e retorne null no método da action.