Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file download

 
Indrayani Bhoir
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
i want to know that is there any way to provide file download option using jsp .
currently i am using follwing code for file download option but as this don't allow any java
script to be used in same page. i am facing some problem.
<%
// fetch the file
String filename = "companySecret.txt";
String filepath = "C:\\";
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();
out.close();
%>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic