I am trying to generate a CSV report so that after generation, the client would be able to download the report to his/her machine. The jsp looks like this:
byte outBytes = myBean.getCSVBytes();
response.setHeader ("Content-Disposition", "attachment;filename=\"ComputeOrder.csv\"");
byte buf = outBytes;
int length = 0;
ServletOutputStream op = response.getOutputStream ();
Now the problem is that when the page is loaded, although the dialogue box is thrown for "Save/Run" application, when i save it to the local machine and open it, i dont see anything. Yes absolute blank. But if I try to print out the bytes in console, i do see output(report content).
What might be wrong?
becuase your length variable is set to 0 and then never changed before your call to op.write(buf,0,length); That calls op.write(buf,0,0); which writes 0 bytes.
Thanks a lot Dave. Also another question... how can I close the window(page on which the download took place)after the download??
Thanks in advance
Thanks a lot