Hi,

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.

Thanks,
Sayaan.

First of all, write extracted data into a CSV file and then download that file.

First of all, write extracted data into a CSV file and then download that file.

If I do that I think the same code can be used only the file writing and reading part will need to be added. Because the code will still read and write to the response buffer for transmission to the client, this time it is from file not from DB.
If you have a different code to download the file please provide.
But what I think the problem is in data transmission from server to client, need to find something to handle it.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.