JSP: I am doing an application in which i have to download ppt file .

Posted by Sanjeev on Stack Overflow See other posts from Stack Overflow or by Sanjeev
Published on 2010-05-03T06:17:53Z Indexed on 2010/05/03 6:28 UTC
Read the original article Hit count: 200

Filed under:
|

I am doing an application in which i have to download ppt file using a jsp page.

I am using The following code but its not working

<% try { String filename = "file/abc.ppt";

// set the http content type to "APPLICATION/OCTET-STREAM response.setContentType("APPLICATION/OCTET-STREAM");

// initialize the http content-disposition header to // indicate a file attachment with the default filename // "myFile.txt" String disHeader = "Attachment Filename=\"abc.ppt\"";

response.setHeader("Content-Disposition", disHeader);

// transfer the file byte-by-byte to the response object File fileToDownload = new File(filename); FileInputStream fileInputStream = new FileInputStream(fileToDownload); int i; while ((i=fileInputStream.read())!=-1) { out.write(i); } fileInputStream.close(); out.close(); }catch(Exception e) // file IO errors { e.printStackTrace(); } %>

can anybody solve this problem...........

© Stack Overflow or respective owner

Related posts about j2ee

Related posts about jsp