I want to trigger my sling servlet on button click and that servlet get trigerred after that and excel file must be downloaded automatically in browser .
I have done the coding its working withot any issue ....but the automatically download iafter clicking on buttton on bbrwser itself in dwoload folder that is what I am not able to acheive
when I work with simple fileoutput stream it works excel file get downloaded and i can open it and see it .(working code )
File excelfile = new File("customisedReport.xlsx");
FileOutputStream fileOutputStream = new FileOutputStream(excelfile);
workbook.write(fileOutputStream);
fileOutputStream.close();
but if i change the above code below like this : it won't work (nothing happens on clicking on button )
String reportName="customisedCommentReport.xlsx";
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename="+reportName);
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
workbook.close();
please suggest what can be the issue
Please note : google chrome i m using , apache poi , XSSFworkbook i used ,