By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,538 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,538 IT Pros & Developers. It's quick & easy.

dynamic file download from servlet

P: n/a
I need to allow a user of my web application to download
a dynamically generated file, in this case from something
I've stored in a database. I am experimenting with this
and the file to download happens to be a pdf file. When
I hit the link from an IE6 browser it pops up a dialog
box asking whether I want to open or save it, which is
exactly the behavior I want. However, when I press the
open button, Acrobat Reader opens (cool) but then it fails

There was an error opening this document, The file does not exist.

When I click on the same link on my linux box, xpdf handles it
just fine.

I think it has something to do with the HTTP header, but I am
not sure. The following is the code of interest:

AttachmentListItem attachment =
EmailSQL.getAttachmentListItem(connection, 3, 1);
response.setContentType(attachment.getContentType( ));
byte[] data =
EmailSQL.getAttachmentBytes(connection, 3, 1);
"attachment; filename=" + attachment.getFileName());
ServletOutputStream out = response.getOutputStream();

Any idea on how to get this to work on my windows box?

Dean Hoover

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.