Saturday, 19 August 2017

how to create Example of Downloading file from the server using JSP

how to create Example of Downloading file from the server using JSP

index.jsp
This file provides a link to download the jsp file.

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

download.jsp
<%
String filename = "home.jsp";
String filepath = "e:\\";
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();
%>

Post a Comment

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search