Java 无法在jsp中加载BIRT图表

Java 无法在jsp中加载BIRT图表,java,jsp,charts,birt,Java,Jsp,Charts,Birt,我在将BIRT图表报告加载到jsp时遇到了一个问题。如果我在报告中使用表格,它会显示得很好,但当我更改为图表时,它只会在jsp中显示空白页。我如何解决这个问题 这是我的html呈现 public Resolution htmlReport() throws EngineException, SemanticException { ByteArrayOutputStream reportOutput = new ByteArrayOutputStream();

我在将BIRT图表报告加载到jsp时遇到了一个问题。如果我在报告中使用表格,它会显示得很好,但当我更改为图表时,它只会在jsp中显示空白页。我如何解决这个问题

这是我的html呈现

public Resolution htmlReport() throws EngineException, SemanticException {
            ByteArrayOutputStream reportOutput = new ByteArrayOutputStream();

            String path = getCompassContext().getServletContext().getRealPath(
                    "/report");

            // @TODO
            String user = getCompassContext().getUser().getUsername();
            birtReport.setUser(user);
            birtReport.setBirtEngine(getCompassContext().getBirtEngine());

            path = CompassConfig.getBirtReport(); //+ "/login_time.rptdesign";
            birtReport.setReportDesignPath(path);
            birtReport.setReportDesignName("/test.rptdesign");
            /**
             * Generates the html report.
             * 
             * @return forward to the jsp page
             * @throws EngineException when opening report design or reunning the report
             * @throws SemanticException when changing properties of DesignElementHandle
             */
             // set output options
                IHTMLRenderOption options = new HTMLRenderOption();

                options.setOutputFormat(IHTMLRenderOption.OUTPUT_FORMAT_HTML);
                options.setOutputStream(reportOutput);
                options.setEmbeddable(false);
               // options.setBaseImageURL(context.getRequest().getContextPath() + "/images");
               //options.setImageDirectory(context.getServletContext().getRealPath("/images"));
                options.setImageHandler(new HTMLServerImageHandler());
                options.setMasterPageContent(true);

               birtReport.generateReport(options);

                return new StreamingResolution("text/html", new ByteArrayInputStream(reportOutput.toByteArray()));
            }
这是我的BIRT引擎

public void generateReport(IRenderOption options) throws EngineException,
            SemanticException {

        generateParamaters();

        // get the engine
        IReportEngine birtReportEngine = birtEngine;

        // open the report design
        String path = reportDesignPath + "/" + reportDesignName;
        IReportRunnable design = birtReportEngine.openReportDesign(path);

        // create task to run and render report
        IRunAndRenderTask task = birtReportEngine
                .createRunAndRenderTask(design);

        Map<String, Object> appContext = task.getAppContext();
        Connection con = DataSourceUtils.getConnection();
        appContext.put("OdaJDBCDriverPassInConnection", con);

        HashMap<String, String[]> multiValParam = getMultiValParam();
        if(multiValParam != null && multiValParam.size() > 0) {
            Set<String> key = multiValParam.keySet();
            Iterator<String> ite = key.iterator();

            while(ite.hasNext()) {
                String paramName = (String) ite.next();
                String[] paramValues = multiValParam.get(paramName);

                task.setParameterValue(paramName, paramValues);
            }
        }
        task.setParameterValues(getParameter());
        task.setRenderOption(options);
        task.setAppContext(appContext);

        // run report
        task.run();
        task.close();
    }
public void generateReport(IRenderOption选项)引发EngineeException,
语义异常{
GenerateParameters();
//取下引擎
IReportEngine birtReportEngine=birtEngine;
//打开报告设计
字符串路径=reportDesignPath+“/”+reportDesignName;
IReportRunnable design=birtReportEngine.openReportDesign(路径);
//创建要运行和呈现报告的任务
IRunAndRenderTask任务=birtReportEngine
.CreateRunandEnderTask(设计);
Map-appContext=task.getAppContext();
Connection con=DataSourceUtils.getConnection();
put(“odajdbdriverpassinconnection”,con);
HashMap multiValParam=getMultiValParam();
if(multiValParam!=null&&multiValParam.size()>0){
Set key=multilparam.keySet();
迭代器ite=key.Iterator();
while(ite.hasNext()){
String paramName=(String)ite.next();
字符串[]paramValues=multiValParam.get(paramName);
task.setParameterValue(paramName,paramValues);
}
}
setParameterValues(getParameter());
task.setRenderOption(选项);
task.setAppContext(appContext);
//运行报告
task.run();
task.close();
}

真的需要帮助

我已经找到了答案..您需要将html呈现放在setEmbeddeble(true)下面

options.setBaseImageURL(getCompassContext().getRequest().getContextPath()+“/images”); options.setImageDirectory(getCompassContext().getServletContext().getRealPath(“/images”)

并且需要将此代码放在appContext.put下面的生成报告中

DesignElementHandle reportChart=design.getDesignHandle().getModuleHandle().findElement(“reportChart”)