bboss session共享时序列化存储jasperreports报表对象JasperPrint方法
bboss session共享组件使用方法介绍
由于JasperPrint对象有点特殊,序列化存储到session时,必须采用java自带的序列化机来序列化和还原JasperPrint对象,否则bboss序列化机制无法实现对原始JasperPrint对象的序列化。具体的设置JasperPrint对象到共享session中的方法如下:
public static void toSession(HttpServletRequest request,String key,JasperPrint jasperPrint) throws IOException
{
java.io.ByteArrayOutputStream out = null;
java.io.ObjectOutputStream output = null;
try
{
out = new ByteArrayOutputStream();
output = new java.io.ObjectOutputStream(out);
output.writeObject(jasperPrint);
output.flush();
request.getSession().setAttribute(key, out.toByteArray());
}
finally
{
try {
if(out != null)
{
out.close();
out = null;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if(output != null)
{
output.close();
output = null;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static JasperPrint getJasperPrint(HttpServletRequest request,String key)
{
JasperPrint jasperPrint = null;
java.io.ObjectInputStream output = null;
java.io.ByteArrayInputStream intput = null;
try
{
byte[] b = (byte[])request.getSession().getAttribute(key);
intput = new ByteArrayInputStream(b);
output = new java.io.ObjectInputStream(intput);
jasperPrint = (JasperPrint)output.readObject();
return jasperPrint;
}
catch(Exception e)
{
e.printStackTrace();
return null;
}
finally
{
try {
if(intput != null)
{
intput.close();
intput = null;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if(output != null)
{
output.close();
output = null;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
下文中提供从共享session中存储和读取jasperprint对象的另外一种更加友好的解决方案:
bboss自定义类对象序列化机制介绍
分享到:
相关推荐
集群会话共享,跨容器跨平台,跨站跨应用会话共享及SSO,高效,配置简单,提供实用的会话统计监控和会话集中管理功能(会话查询,会话删除,会话属性数据查看等等)
Bboss和xstream序列化反序列化性能对比1
bboss会话共享培训文档,学习bboss不可多得的资料,值得拥有。
NULL 博文链接:https://yin-bp.iteye.com/blog/2177475
bboss es特点请访问: https://www.oschina.net/p/bboss-elastic
Bboss国际化实践.ppt
企业级 J2EE 开源框架:bboss
bboss会话共享源码 github托管地址: svn下载地址 bboss演示源码 github托管地址: svn下载地址 基于bboss的开源工作流Activiti5.12 github托管地址 svn下载地址 自动代码生成框架github源码托管地址和svn下载...
bboss+es基本操作示例,elasticsearch,bboss,java使用demo
bboss-datatran 由 bboss 开源的数据采集&流批一体化工具,提供数据采集、数据清洗转换处理和数据入库以及数据指标统计计算流批一体化处理功能。
NULL 博文链接:https://yin-bp.iteye.com/blog/926166
springboot集成ElasticsearchBboss调用Elasticsearch的案例分享
官方版本,亲测可用
资源目录: 项目源码(eshelloword.rar) bboss elasticsearch开发入门教程.wmv 搭建bboss elasticsearch开发环境.wmv 说明.txt
Elasticsearch rest client bboss介绍-Elastic2018中国开发者大会演讲稿
NULL 博文链接:https://yin-bp.iteye.com/blog/2174863
浙江移动BBOSS系统快速入门手册V0.1归类.pdf
NULL 博文链接:https://yin-bp.iteye.com/blog/1131637
bboss功能涵盖ioc,mvc,jsp自定义标签库,持久层,全局事务托管,安全认证,SSO,web会话共享,cxfwebservice服务发布和管理,hessian服务发布和管理等功能。另外还提供了符合中国式自由流的bboss activiti工作流...
NULL 博文链接:https://yin-bp.iteye.com/blog/1449900