Verifique se vc está fazendo algo semelhante à isso:
try {
String relatorio = gerarRelatorio(); // método fictício
String nomeArquivo = "arquivo.txt"; // supondo que seja um txt, mas funciona com qq arquivo
FileOutputStream fileOut = new FileOutputStream(nomeArquivo);
fileOut.write(relatorio.getBytes());
fileOut.flush();
fileOut.close();
response.setContentType("inline/download");
String arq = "attachment;filename=" + nomeArquivo;
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();
}
Vê se isso te ajuda! Falow! :mrgreen: