Problems with downloading functionality
PeterNorval <[email protected]> Thu, 12 May 2005 10:42:16 CDT
| Newsgroups | gmane.comp.web.sitemesh.general |
|---|---|
| Message-ID | <25073043.1115912566797.JavaMail.os-j2ee@opensymphony01.contegix.com> |
Hi there, I've recently come accross this problem too and have had to revert to an older version to get around it.
I have some pdf's hosted securely on a server and just want them available to download. the code I use is as follows. This is called from within a struts action:
response.reset();
response.setContentLength((int) file.length());
response.setContentType("application/unknown");
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\";");
OutputStream os = response.getOutputStream();
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
InputStream is = new BufferedInputStream(bis);
byte buffer[] = new byte[4096];
int count = 0;
while ((count = is.read(buffer)) > -1)
{
os.write(buffer, 0, count);
}
is.close();
os.close();
As I said, this exact code works with an older version of sitemesh, but not 2.2.1. Any help would be most appreciated.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=2071&messageID=6453#6453
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]