我从数据库中检索的PDF文件,并把它放在一个文件中像这样
String str="select * from files where name='Security.pdf';";
Statement stmt2= conn.createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = stmt2.executeQuery(str);
while(rs.next())
{
InputStream input = rs.getBinaryStream("content");
//to create file
File f=new File("c:/pdfile.pdf");
OutputStream out=new FileOutputStream(f);
byte buf[]=new byte[1024];
int len;
while((len=input.read(buf))>0)
out.write(buf,0,len);
out.close();
input.close();
System.out.println("\nFile is created..");
}
现在,这是在服务器端。在我的客户端,每当用户点击一个链接时,我的jsp页面上应该显示一个链接 href = pdf(pdf是我的servlet名称),我应该在客户端的浏览器上显示从数据库检索到的文件。
我该怎么办?
2012-04-27
suraj