Problem in downloading csv file generated on the server

nareshpillai
nareshpillai used Ask the Experts™
on
I am creating a csv file dynamically by querrying into the database and it will show the download button on clicking on it the csv file should be download, but instead it opens up in the browser. I need help how to make the file to download to the client using jsp
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I need to solution on urgent basis..

Commented:
out.addHeader("content-disposition","attachment; filename=cf148.doc")

make sure you do this before any content is written to the browser.  This will always force the "download" dialog.

Commented:
BTW the "filename" doesn't matter...put whatever you like..."myfile.csv"

Author

Commented:
the method addHeader does not work as it shows an error that addHeader method not found in class javax.servlet.jsp.JspWriter. Can you provide me with an solution
Commented:
So Sorry!  Mistake in my code:

try:

response.addHeader(....

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial