I'm new in jsp development
I'm trying to download a txt file.
My jsp code is the following
<% String filepath="D:/Wok-Niva/Page/WebContent/UploadFile";
String filename="java.txt";
try{
response.setContentType("text/plain");
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
FileInputStream fileInputStream=new java.io.FileInputStream(filepath +"/"+ filename);
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
}catch(Exception e)
{
out.print(e);
}
%>
When I download the txt file, I get something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
computer science
</body>
</html>
But the content of my text file is only "computer science"