当用户点击按钮时,客户端浏览器上的windchill GUI应该在他的系统上下载特定的pdf文件.我已经通过使用以下代码实现了这一点.
<body>
<%
String pdfname= session.getAttribute("pdfname").toString();
String Pdfpath= session.getAttribute("pdfpath").toString();
File f =new File(Pdfpath);
Boolean flag=false;
if(f.exists())
{
BufferedInputStream filein = null;
BufferedOutputStream out2=null;
try {
File file = new File(Pdfpath);//specify the file path
byte b[] = new byte[1048576];
int len = 0;
filein = new BufferedInputStream(new FileInputStream(file));
out2=new BufferedOutputStream(response.getOutputStream());
response.setHeader("Content-Length", ""+file.length());
response.setContentType("application/pdf");
response.setHeader("Content-Disposition","attachment;filename="+pdfname);
response.setHeader("Content-Transfer-Encoding", "binary");
while ((len = filein.read(b)) > 0) {
out2.write(b, 0, len);
out.println("Your Pdf Document Is Generated Please close it");
}
filein.close();
out2.flush();
out2.close();
}
catch(Exception …Run Code Online (Sandbox Code Playgroud)