title: Java save as dialog box to save a file at a path
body: <p>I have a form that takes a <code>PDF</code> 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.</p>
  
  <pre><code>            HSSFWorkbook workbook = new HSSFWorkbook();
              HSSFSheet sheet = workbook.createSheet("Data");
  
              ArrayList&lt;String&gt; keys = new ArrayList&lt;String&gt;(excelData.keySet());
  
              int counter = 0;
  
              for(int i=keys.size()-1; i&gt;=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);  
              }
  </code></pre>
  
  <p>//work book is the xls data that currently I am saving like , </p>
  
  <pre><code>                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"));
  </code></pre>
  
  <p>Instead of saving file directly to <code>C:\\Users\\user\\Desktop\\new.xls</code>,I want  to give a <code>save as</code> option to select the path and name of the file that user want to save. Some thing like : </p>
  
  <p><a href="https://i.stack.imgur.com/s8hYK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s8hYK.png" alt="enter image description here"></a></p>
  
  <p>How can I send this file back to the client browser and show save as option.</p>