-2
我正在为一家电子商务公司工作,我的项目负责人给了我这个用例......我必须调用一个PL包(我知道该怎么做),并且用输出参数(pdf文件名) ,我必须在服务器中查找文件并将其显示在页面中......任何人都可以提供一个想法?... Thanxk!在一个页面中显示一个PDF文件,其中的名称是从PL包中获得的?
我正在为一家电子商务公司工作,我的项目负责人给了我这个用例......我必须调用一个PL包(我知道该怎么做),并且用输出参数(pdf文件名) ,我必须在服务器中查找文件并将其显示在页面中......任何人都可以提供一个想法?... Thanxk!在一个页面中显示一个PDF文件,其中的名称是从PL包中获得的?
从http://snippets.dzone.com/posts/show/4629(后谷歌 “的servlet下载文件” 搜索):
private void doDownload(HttpServletRequest req, HttpServletResponse resp,
String filename, String original_filename)
throws IOException
{
File f = new File(filename);
int length = 0;
ServletOutputStream op = resp.getOutputStream();
ServletContext context = getServletConfig().getServletContext();
String mimetype = context.getMimeType(filename);
//
// Set the response and go!
//
//
resp.setContentType((mimetype != null) ? mimetype : "application/octet-stream");
resp.setContentLength((int)f.length());
resp.setHeader("Content-Disposition", "attachment; filename=\"" + original_filename + "\"");
//
// Stream to the requester.
//
byte[] bbuf = new byte[BUFSIZE];
DataInputStream in = new DataInputStream(new FileInputStream(f));
while ((in != null) && ((length = in.read(bbuf)) != -1))
{
op.write(bbuf,0,length);
}
in.close();
op.flush();
op.close();
}
搜索在谷歌 “的servlet下载文件” – 2012-03-02 18:54:24