Skip to Main Content

Application Development Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

set http header / Content Type for file download

Ghazi HakimMay 23 2014 — edited Jun 8 2014

Hello,

I need to allow end users of my site to download excel/csv files from the server,

the classic method is set header of the response in a jsp :

index.jsp

<a href="download.jsp">download the file</a>


download.jsp :

<%  
 
String filename = "file.xls";  
 
String filepath = "C:\\Files\\";  
  response
.setContentType("APPLICATION/OCTET-STREAM");  
  response
.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");  

  java
.io.FileInputStream fileInputStream=new java.io.FileInputStream(filepath + filename); 

 
int i;  
 
while ((i=fileInputStream.read()) != -1) { 
  out
.write(i);  
 
}  
  fileInputStream
.close();  
%>

but it's not working with 2 Pages Template with Fatwire 7.6.2,

Is that because I am not allowed to use "response" in Fatwire ?

Regards,

Ghazi.


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2014
Added on May 23 2014
4 comments
3,812 views