[英]how to invoke jsp page from my index.html file?
I want to invoke my jsp page from my index.html.This is html code. 我想从index.html调用我的jsp页面。这是html代码。
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<form action="DownloadFile.jsp">
<body>
<div>Click here Download File from Server...</div>
<input type="submit" name="downloadButton" value="Download..." />
</body>
</form>
</html>
JSP PAGE:
<%
String filename = "Sample1.zip";
String filepath = "e:\\temp\\";
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 When i pressing Download Button, it just shows the jsp file content as html.it does not start downloading the file anyway. 但是当我按下Download Button时,它只是将jsp文件内容显示为html.it仍然不会开始下载文件。 What is the problem here...
这里有什么问题...
and also i cann't download .docx and .jpg files correctly.It says file may be corrupted... 而且我无法正确下载.docx和.jpg文件。它说文件可能已损坏...
Please Guide me to get out of this both issues... 请指导我摆脱这两个问题...
Is there a common way to download all types of files in jsp? 有没有一种通用的方法可以在jsp中下载所有类型的文件?
Your server either does not support JSP or is not configured for it. 您的服务器不支持JSP或未为其配置。
You need a JSP capable server. 您需要一个支持JSP的服务器。
您是否已与Web服务器一起配置了Servlet引擎,并完成了将jsp文件请求转发到服务器引擎的设置。
Actually, you do not need jsp to download you content . 实际上,您不需要jsp即可下载content。 Instead, if you want to download from the client end, you can use html5
相反,如果要从客户端下载,可以使用html5
<!DOCTYPE html>
<html>
<body>
<p>Click on the below hyperlink to download the any such file:<p>
<a href="5.csv" download>
test
</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.