open an excel file

Hi,

When a user click a link "say "Export to Excel" on a jsp then i have a servlet whcih gets the data from that JSP and prepares an excel sheet and now in the above servlet i am setting

response.setHeader("Cache-Control", "no-cache");

response.setContentType("application/vnd.ms-excel");

response.setHeader("Content-disposition",attachment; filename=abc.xls)

Now what is happening is when the user is clicking the link i am getting a pop up saying

Do u want to open or save the excel sheet .

If i tried to save it then its fine.But when i tried to open it I am getting error File not found.

Can anyone tell me what is the reason for it.

It would be great if any one answers my question .

Thanks in advance .

[778 byte] By [rakesh_bhadraa] at [2007-11-27 4:40:37]
# 1
Hi,You can try with response.setContentType("application/x-download");Regards,Suresh
Suresh_in80a at 2007-7-12 9:51:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
> Hi,> > You can try with> response.setContentType("application/x-download");> > Regards,> SureshHi ,I am still getting the error while opening the file.
rakesh_bhadraa at 2007-7-12 9:51:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Your contenttype is OK, also see http://www.w3schools.com/media/media_mimeref.asp

But you're missing at least the contentlength, so that the app doesn't know before how big the file is and therefore cannot estimate the download. Some (older) appls will crash on this.

You may find the downloadFile() utility snippets at the bottom of the http://balusc.xs4all.nl/srv/dev-jep-pdf.html useful.

BalusCa at 2007-7-12 9:51:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...