0
我想出來像下載任何選項,在JSP小框查看PDF文件,view.please給java源例如如何查看PDF文件中的小框在JSP
File f= new File(file);
if(f.exists()){
ServletOutputStream op= response.getOutputStream();
response.reset();
if(check==1){
response.setContentType("application/pdf");
}else{
response.setContentType(content);
}
// response.setHeader("Content-disposition","attachment; filename=" +fileName);
byte[] buf = new byte[4096];
int length;
DataInputStream in = new DataInputStream(new FileInputStream(f));
while ((in != null) && ((length = in.read(buf)) != -1)){
op.write(buf,0,length);
}
in.close();
op.flush();
op.close();
}
and already i done download pdf file use this code