I have written a jsp page which extract large data (1.5MB) from database and downloaded to a csv file.
The browser promtpts a file save dialog box and user can save it in csv file in local drive.
The program works fine only problem is, in csv file there are many blank lines after a chunk of data (around 2KB). So it is 2KB of data then many blank lines and again 2KB of data and then again many blank lines and so on.
Do anyone know how to solve this problem.
Here is the code I used:
<% response.setContentType("application/text"); response.addHeader("Content-Disposition", "attachment; filename=WIC001_KFX_Detail.csv"); PrintWriter pw = response.getWriter(); then data extraction from DB loop through the records set write to the buffer using write() method. and then pw.flush(); pw.close(); %>
It will be very helpful if anyone can provide solution.