|
Re: Embedded Images are not appearing in Web logic [message #762256 is a reply to message #761928] |
Wed, 07 December 2011 19:06   |
|
My guess is the sc.getRealPath is returning null when you are trying to
set the image directory.
Take a look at this post:
http://reach2ramesh.blogspot.com/2010/01/weblogic-servletcontextgetrealpath.html#!/2010/01/weblogic-servletcontextgetrealpath.html
Jason
On 12/7/2011 4:50 AM, shabz wrote:
> We have integrated BIRT in our application and sample code is as below. the images are embedded in reports. Now the problem is that images are appearing in tomcat but not in weblogic (attached screenshot).
>
>
> // get report name and launch the engine
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> String path=ApplicationBase.getInstance().getInitHash().getProperty("BIRT_WORKING_FOLDER");
> String reportName = request.getParameter("ReportName");
> ServletContext sc = request.getSession().getServletContext();
> this.birtReportEngine = BirtEngine.getBirtEngine(sc);
>
> // setup image directory
> HTMLRenderContext renderContext = new HTMLRenderContext();
> renderContext.setBaseImageURL(request.getContextPath() + "/images");
> renderContext.setImageDirectory(sc.getRealPath("/images"));
>
> HashMap<String, HTMLRenderContext> contextMap = new HashMap<String, HTMLRenderContext>();
> contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);
>
> IReportRunnable design;
> try {
> // Open report design
> RequestParameterObject rpo = QueryCrypt.getInstance().decrypt(request);
> String name = rpo.getParameter("ReportName");
> reportName=name;
> design = birtReportEngine.openReportDesign(path+"/birtreports" + "/" + reportName);
> System.out.println("::::::path::::::"+path+"/birtreports" + "/" + reportName);
> // create task to run and render report
> IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(design);
> task.setAppContext(contextMap);
>
> // set output options
> HTMLRenderOption options = new HTMLRenderOption();
> options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
> options.setEmbeddable(true);
> options.setOutputStream(out);
> task.setRenderOption(options);
>
> ReportParameters rpm = new ReportParameters();
> task = rpm.setReportParameters(rpo,task);
>
> task.getAppContext().put("OdaJDBCDriverPassInConnection", DBaseBirt.getConnection());
>
> // run report
> task.run();
> task.close();
> } catch (Exception e) {
> logger.log(Level.SEVERE, e.getMessage(), e);
> throw new ServletException(e);
> }
> return out;
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02730 seconds