title: Generate/download CSV file without storing on server
body: <p>I'm using the apache.commons.csv library in Java to generate CSV and make it downloadable without storing on server using following code:</p>
  
  <pre><code>try (OutputStreamWriter osw = new OutputStreamWriter(response.getOutputStream())){
          csvWriter = new CSVPrinter(osw,CSVFormat.DEFAULT);
  
          writer.printRecord(row);
          response.setContentType("text/csv");
          response.setHeader("Content-disposition", "attachment; filename=\"" + fileName + "\";");
  catch(Exception e) {
          //Exception block
  }
  finally {
          try {
              csvWriter.flush();
          } catch (IOException e) {
              logger.error("Exception while flushing file writer and CSV writer",e);
          }
  
      }
  </code></pre>
  
  <p>But it showing csv on browser, rather than asking me save as option for download.</p>
  
  <p>What is wrong in the code or is there any other way to do the same?</p>