Hi,
I'm having a very strange problem with downloading documents. Most of my
users have no issue, but a small subset are experiencing some problems.
One set can open the document directly into an application (such as
word) but cannot save the document. Others have exactly the opposite
behaviour. A failure simply doesn't work -- nothing opens or nothing
gets saved.
On various browsers, I can do both -- my apache and application server
logs show no errors.
Any comments are gratefully accepted.
The code that sends the file is as follows
public void doPost(HttpServletRequest req, HttpServletResponse
res)
throws ServletException, IOException {
OutputStream obf = res.getOutputStream();
Response responseObj;
Hashtable respHash;
responseObj = (Response)
req.getAttribute("responseObj");
respHash = responseObj.getHash();
byte[] buf = (byte[]) respHash.get("FILEBUFF");
String f_Name = (String) respHash.get("FILENAME");
int fileSize = buf.length;
res.setHeader("Content-disposition", "attachment;
filename=" + f_Name);
int pos;
String ext;
pos = f_Name.lastIndexOf(".");
ext = f_Name.substring(pos + 1).toLowerCase();
if (ext.equals("doc")) {
res.setContentType("application/msword");
} else if (ext.equals("pdf")) {
res.setContentType("application/pdf");
} else {
res.setContentType("application/octet-stream");
}
res.setContentLength(fileSize);
obf.write(buf);
obf.flush();
obf.close();
}
}
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com