In How to export data in CSV format using Java?, I found a solution to write the date to CSV files and the accepted answer works fine.
I need change file name to anything with .csv extention. Now I get WebServlet name as a file name without any extention.
Do you have any idea how to set a file name?
resp.setContentType("application/csv");
PrintWriter w = resp.getWriter();
w.println(generateCsvFile(policies));
w.flush();
w.close();