I'm using the poi 3.15 library to generate excel on a web system, but I'm having a hard time downloading the file locally, but when I do it does nothing. I put it in the beginning like this:
String caminho = System.getProperty("user.home");
String filename = caminho + "/arquivo.xls";
At the end:
try (FileOutputStream fileOut = new FileOutputStream(filename)) {
workbook.write(fileOut);
}
and in the servlet I call:
case "EXPORTAR":
new ClasseDAO().exportarExcel(id);
dispatcher = request.getRequestDispatcher("pagina.jsp");
dispatcher.forward(request, response);
break;
The call is in the action of a form, I tried setting ContentType with vnd.ms-excel, Header with attachment but it does not work.