I have a form that takes a PDF
file and submits to servlet. After reading the content of PDF I am creating a xls file in servlet using Apache POI that I want to save to my local disc.
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Data");
ArrayList<String> keys = new ArrayList<String>(excelData.keySet());
int counter = 0;
for(int i=keys.size()-1; i>=0;i--){
String key = keys.get(i);
String value = excelData.get(key);
Row row = sheet.createRow(counter++);
Cell cell = row.createCell(0);
cell.setCellValue(key);
Cell cell1 = row.createCell(1);
cell1.setCellValue(value);
}
//work book is the xls data that currently I am saving like ,
FileOutputStream out = new FileOutputStream(new File("C:\\Users\\user\\Desktop\\new.xls"));
workbook.write(out);
out.close();
//return back to same page.
response.sendRedirect(request.getHeader("Referer"));
Instead of saving file directly to C:\\Users\\user\\Desktop\\new.xls
,I want to give a save as
option to select the path and name of the file that user want to save. Some thing like :
How can I send this file back to the client browser and show save as option.