Hello all, I am having a little trouble reading a file off the server and displaying it to the user for viewing. I am receiving the following error from explorer:
Internet explorer cannot download ...viewFile.do?fileId=8 from localhost. Internet explorer was not able to open this internet site. The requested site is either unavailable or cannot be done. Please try again later. This is some of the code that I am using in my action class: ... try { response.setContentType(myFile.getContentType()); response.setContentLength(myFile.getLength()); BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream()); FileInputStream fis = new FileInputStream(myFileFile); byte[] buffer = new byte[1024]; int bytes_read; while((bytes_read = fis.read(buffer)) != -1) { bos.write(buffer, 0, bytes_read); } fis.close(); bos.close(); } catch (Exception e) { getServlet().log("ViewFileAction.executeAction " + "Exception: " + e.getMessage()); System.out.println(">>>>>ERROR!!!! " + e.getMessage()); e.printStackTrace(); throw new SystemException(e); } return null; The contentType and contentLength are being set correctly. Because there is nothing to do after writing the file to the browser, I return a null ActionForward. Any suggestions here? Is an action the wrong place to put this code? I am hoping to generate a popup with the file displayed in it. Regards, Joshua This communication, including attachments, is for the exclusive use of addressee and may contain proprietary, confidential or privileged information. If you are not the intended recipient, any use, copying, disclosure, dissemination or distribution is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return email and delete this communication and destroy all copies. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]