OAF 中下载使用XML Publisher下载PDF附件
OAF doesn't readily expose the Controller Servlet's HttpRequest and HttpResponse objects so you need to extract it from the OAPageContext object via:
HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();
Once you get the response object you could already manipulate its OutputStream.
public void downloadFile(OAPageContext pageContext) {
HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();
File fileToDownload = this.createFile();
String fileType = getMimeType("txt");
response.setContentType(fileType);
response.setContentLength((int) fileToDownload.length());
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileToDownload.getName() + "\"");
InputStream in = null;
ServletOutputStream outs = null;
try {
outs = response.getOutputStream();
in = new BufferedInputStream(new FileInputStream(fileToDownload));
int ch;
while ((ch = in.read()) != -1) {
outs.write(ch);
}
} catch (IOException e) {
// TODO
e.printStackTrace();
} finally {
try {
outs.flush();
outs.close();
if (in != null) {
in.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
参考资料:
Integrate XML Publisher and OA Framework
Downloading Files in OAF (需翻墙)
OAF 中下载使用XML Publisher下载PDF附件的更多相关文章
- 在页面和请求中分别使用XML Publisher生成PDF报表且自动上传至附件服务器
两个技术要点: 1.使用TemplateHelper.processTemplate方法生成目标PDF的InputStream流,再使用ftp中上传流的方法将其上传至附件服务器. 2.在请求中调用AM ...
- 使用XML Publisher导出PDF报表
生成XML数据源有两种方式. 一种是使用存储过程,返回一个clob作为xml数据源. 另一种是直接使用VO中的数据生成xml数据源. 方法一参考: Oracle XML Publisher技巧集锦 O ...
- 【资源】108个大数据文档PDF开放下载-整理后打包下载
本博客所有文章分类的总目录:http://www.cnblogs.com/asxinyu/p/4288836.html 本博客其他.NET开源项目文章目录:h ...
- OAF与XML Publisher集成(转)
原文地址:OAF与XML Publisher集成 有两种方式,一种是用VO与XML Publisher集成,另一种是用PL/SQL与XML Publisher集成 用VO与XML Publisher集 ...
- Http协议的断点续传下载器,使用观察者模式监视下载进度,使用xml保存下载进度。
下载使用Http协议,为了做到断点续传,在点击暂停后,将已下载的大小等数据通过Json存入xml中,当继续传输的时候从xml文件中读取大小继续下载(好几个月前写的,真的想不起来了) bool CHtt ...
- JAVA中使用FTPClient上传下载
Java中使用FTPClient上传下载 在JAVA程序中,经常需要和FTP打交道,比如向FTP服务器上传文件.下载文件,本文简单介绍如何利用jakarta commons中的FTPClient(在c ...
- iOS7 中的新加入的下载类NSURLSession(随ios版本更新而更新)
想详细的了解网络下载的相关知识,要仔细阅读URL Loading System Programming Guide 这里有篇好文章(http://www.shinobicontrols.com/blo ...
- python中模块包的离线下载教程
1.简介 当我们进行Python项目的迁移时(例如迁移到另外一台服务器上),如果该服务器要求离线安装, 往往需要我们将项目中的所需模块包进行离线操作. 2.教程 2.1 首先安装pip2pi模块,它可 ...
- Linux中从oracle官网下载jdk文件不是标准的gzip格式文件问题
首先你要知道,在linux系统中,文件类型跟后缀名无关,后缀名只是为了方便识别,所以你下载的压缩包可能是tar.gz格式的,也有可能是tar.bz2或tar.xz格式,因为可能别人压缩之后不小心改错了 ...
随机推荐
- live555 编译
项目里面需要简单的rtsp服务器来实现视频预览等功能: rtsp本来不是太复杂的东西,github上有很多功能都比较完善的项目可以随便拿来用,但是测试过程中发现live555还是有性能上的一些差异: ...
- PHP 验证码:扭曲+粘连+变形
一,绪论 由于项目需要,需要加强目前的验证码,我们参照的对象是支付宝. 基于PHP CodeIgniter 框架,代码放置在下面的路径下. /application/libraries 二,主要代码 ...
- ELK之elasticsearch6.5集群
前面介绍并初试了es6.5系列的单节点的操作,现在搭建es6.5系列的集群: 环境:三节点:master-172.16.23.128.node1-172.16.23.129.node2-172.16. ...
- Python3基础 os chdir 改变工作目录
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- [codeWars] - 8kyu的简单复习
https://www.codewars.com/kata/5aa736a455f906981800360d public class Kata { public static boolean fea ...
- NS3 MyApp Class Reference
官方文档:MyApp 可以在下面的几个例子找到: examples/tutorial/fifth.cc examples/tutorial/seventh.cc examples/tutorial/s ...
- Windows 2003 server下载
http://www.downza.cn/soft/182837.html或http://www.imsdn.cn/operating-systems/windows-server-2003/
- pip 安装pandas报UnicodeDecodeError: 'ascii' codec can't decode byte 0xd5错
当Python在window环境中通过pip安装pandas报标题这样的错,主要是因为python默认编码格式是:ascii 在https://www.python.org/dev/peps/pep- ...
- java编程思想之并发(死锁)
一个对象可以有 synchronized 方法或其他形式的加锁机制来防止别的任务在互斥还没有释放的时候就访问这个对象. 死锁 任务有可能变成阻塞状态,所以就可能发生这样的情况:某个任务在等待另一个任务 ...
- /var/run/dbus/system_bus_socket no such file or directory
参考:http://fixmyos.blogspot.jp/2011/10/failed-to-connect-to-socket.html /var/run/dbus/system_bus_sock ...