Java 类net.sf.jasperreports.engine.export.JRHtmlExporterParameter 实例源码

项目:bdf2    文件:HtmlExporter.java   
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
    res.setContentType("text/html;charset=UTF-8");
    JRHtmlExporter exporter=new JRHtmlExporter(DefaultJasperReportsContext.getInstance());
    JasperPrint jasperPrint=this.getJasperPrint(req);
    req.getSession().setAttribute(BaseHttpServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
    OutputStream ouputStream = res.getOutputStream();
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
    String path=req.getContextPath();
    if(path.endsWith("/")){
        path+="dorado/bdf2/jasperreports/html.image";
    }else{
        path+="/dorado/bdf2/jasperreports/html.image";          
    }
    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,path+"?image=");
    try {
        exporter.exportReport();
    } catch (JRException e) {
        throw new ServletException(e);
    } finally {
        if (ouputStream != null) {
            ouputStream.flush();
            ouputStream.close();
        }
    }
}
项目:ireport-fork    文件:HtmlExportParametersPanel.java   
public void load() {
    setInit(true);
    Preferences pref = IReportManager.getPreferences();
    JRPropertiesUtil jrPropUtils = IRLocalJasperReportsContext.getUtilities();
    JasperReportsContext context = IRLocalJasperReportsContext.getInstance();

    jCheckBoxFrameAsNestedTables.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES)));
    jCheckBoxRemoveEmptySpace.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS)));
    jCheckBoxSaveImages.setSelected( pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.saveImages", true));
    jCheckBoxUseImagesToAlign.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN)));
    jCheckBoxWhiteBackground.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));
    jCheckBoxWrapBreakWord.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD)));

    jTextFieldImagesDirectory.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory",""));
    jTextFieldImagesDirectory1.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri",""));

    jTextAreaHtmlBetweenPages.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages",""));
    jTextAreaHtmlFooter.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter",""));
    jTextAreaHtmlHeader.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader",""));
    jComboBox1.setSelectedItem(  pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)));
    setInit(false);
}
项目:ireport-fork    文件:HtmlExportParametersPanel.java   
public void store() {

        Preferences pref = IReportManager.getPreferences();

        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES,  jCheckBoxFrameAsNestedTables.isSelected() );
        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,  jCheckBoxRemoveEmptySpace.isSelected() );
        pref.putBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.saveImages",  jCheckBoxSaveImages.isSelected() );
        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN,  jCheckBoxUseImagesToAlign.isSelected() );
        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND,  jCheckBoxWhiteBackground.isSelected() );
        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD,  jCheckBoxWrapBreakWord.isSelected() );

        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory", jTextFieldImagesDirectory.getText());
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri", jTextFieldImagesDirectory1.getText());
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages", jTextAreaHtmlBetweenPages.getText());
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter", jTextAreaHtmlFooter.getText());
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader", jTextAreaHtmlHeader.getText());
        pref.put(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jComboBox1.getSelectedItem()+"");

      }
项目:gnvc-ims    文件:OOReportGenerator.java   
private void exportToHTML() {
    log.debug("exporting to HTML");
    htmlExporter = new JRHtmlExporter();
    setExportParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
    setExportParameter(JRHtmlExporterParameter.IMAGES_URI,"servlets/image?image=");
    setExportParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.TRUE);
    setExportParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
    setExportParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
    htmlExporter.setParameters(getExportParameters());
    try {
        start = System.currentTimeMillis();
        htmlExporter.exportReport();
        log.info("export running time (msec): "
                + (System.currentTimeMillis() - start));
    } catch (JRException jre) {
        jre.printStackTrace();
    }
}
项目:nextreports-server    文件:JasperReportsUtil.java   
public static byte[] getHTML(StorageService storageService, JasperPrint jasperPrint)
        throws JRException {
    byte[] content = null;
    ByteArrayOutputStream baos = null;
    try {
        baos = new ByteArrayOutputStream();
        JRHtmlExporter exporter = new JRHtmlExporter();
        // Jasper Images will be stored to reports home directory
        // so to be accesed from HTML
        exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME, storageService.getSettings().getReportsHome());
        exporter.setParameter(JRHtmlExporterParameter.SIZE_UNIT, "px");
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "./");
        content = getBytes(exporter, baos, jasperPrint);
    } finally {
        if (baos != null) {
            try {
                baos.flush();
                baos.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return content;
}
项目:spring4-understanding    文件:JasperReportsUtilsTests.java   
@Test
public void renderAsHtmlWithExporterParameters() throws Exception {
    StringWriter writer = new StringWriter();
    Map<JRExporterParameter, Object> exporterParameters = new HashMap<JRExporterParameter, Object>();
    String uri = "/my/uri";
    exporterParameters.put(JRHtmlExporterParameter.IMAGES_URI, uri);
    JasperReportsUtils.renderAsHtml(getReport(), getParameters(), getData(), writer, exporterParameters);
    String output = writer.getBuffer().toString();
    assertHtmlOutputCorrect(output);
    assertTrue("URI not included", output.contains(uri));
}
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configureXHtmlExporter(JRExporter exporter, SimpleJasperReportsContext context) {

        Preferences pref = IReportManager.getPreferences();
        JRPropertiesUtil jrPropUtils = JRPropertiesUtil.getInstance(context);

        exporter.setParameter( JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.saveImages", true));
        exporter.setParameter( JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));
        exporter.setParameter( JRHtmlExporterParameter.IS_WRAP_BREAK_WORD, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD)));

        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter",""));
        }
        if (pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)).length() > 0)
        {
            context.setValue( JRHtmlExporterParameter.PROPERTY_SIZE_UNIT , pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)));
        }

    }
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configureHtmlExporter(JRExporter exporter, SimpleJasperReportsContext context) {

        Preferences pref = IReportManager.getPreferences();
        JRPropertiesUtil jrPropUtils = JRPropertiesUtil.getInstance(context);

        context.setValue( JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES)));
        context.setValue( JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS)));
        exporter.setParameter( JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.saveImages", true));
        context.setValue( JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN)));
        context.setValue( JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));
        context.setValue( JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD)));

        //FIXME these properties do not actually exist!!!!!!!..... check all properties

        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader","").length() > 0)
        {
            context.setValue(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter", pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter",""));
        }
        if (pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)).length() > 0)
        {
            context.setValue( JRHtmlExporterParameter.PROPERTY_SIZE_UNIT , pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)));
        }

    }
项目:class-guard    文件:ExporterParameterTests.java   
public void testTypeConversion() {
    Map params = new HashMap();
    params.put("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN", "true");

    AbstractJasperReportsView view = new JasperReportsHtmlView();
    setViewProperties(view);

    view.setExporterParameters(params);
    view.convertExporterParameters();
    Object value = view.getConvertedExporterParameters().get(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN);
    assertEquals(Boolean.TRUE, value);
}
项目:class-guard    文件:JasperReportsHtmlViewTests.java   
public void testConfigureExporterParametersWithEncodingFromPropertiesFile() throws Exception {
    GenericWebApplicationContext ac = new GenericWebApplicationContext();
    ac.setServletContext(new MockServletContext());
    BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(ac);
    reader.loadBeanDefinitions(new ClassPathResource("view.properties", getClass()));
    ac.refresh();

    AbstractJasperReportsView view = (AbstractJasperReportsView) ac.getBean("report");
    String encoding = (String) view.getConvertedExporterParameters().get(JRHtmlExporterParameter.CHARACTER_ENCODING);
    assertEquals("UTF-8", encoding);

    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
    view.render(getModel(), request, response);
    assertEquals("Response content type is incorrect", "text/html;charset=UTF-8", response.getContentType());
}
项目:class-guard    文件:JasperReportsUtilsTests.java   
public void testRenderAsHtmlWithExporterParameters() throws Exception {
    StringWriter writer = new StringWriter();
    Map<JRExporterParameter, Object> exporterParameters = new HashMap<JRExporterParameter, Object>();
    String uri = "/my/uri";
    exporterParameters.put(JRHtmlExporterParameter.IMAGES_URI, uri);
    JasperReportsUtils.renderAsHtml(getReport(), getParameters(), getData(), writer, exporterParameters);
    String output = writer.getBuffer().toString();
    assertHtmlOutputCorrect(output);
    assertTrue("URI not included", output.contains(uri));
}
项目:enterprise-app    文件:AbstractReport.java   
protected JRHtmlExporter getHtmlExporter() {
    JRHtmlExporter exporter = new JRHtmlExporter();
    String random = "" + Math.random() * 1000.0;
    random = random.replace('.', '0').replace(',', '0');

    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, Utils.getWebContextPath(EnterpriseApplication.getInstance()) + "/image?r=" + random + "&image=");
    return exporter;
}
项目:konekti    文件:TemplateComponentReport.java   
protected JRHtmlExporter getHtmlExporter() {
    JRHtmlExporter exporter = new JRHtmlExporter();
    String random = "" + Math.random() * 1000.0;
    random = random.replace('.', '0').replace(',', '0');

    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, getWebContextPath() + "/image?r=" + random + "&image=");
    return exporter;
}
项目:konekti    文件:GridComponentReport.java   
protected JRHtmlExporter getHtmlExporter() {
    JRHtmlExporter exporter = new JRHtmlExporter();
    String random = "" + Math.random() * 1000.0;
    random = random.replace('.', '0').replace(',', '0');

    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, getWebContextPath() + "/image?r=" + random + "&image=");
    return exporter;
}
项目:gesplan    文件:RelatorioHtml.java   
/**
  * metodo responsavel pelo preenchimento do relatorio, a partir do arquivo jasper compilado, do nome do arquivo html, 
  * e considerando os dados sob a forma de List e os par�metros 
  * 
  * @param nomeArquivo
  * @param streamRelatorio
  * @param parametros
  * @param dados
  * @throws RelatorioException
  */
 public void download(String nomeArquivo, InputStream streamRelatorio, Map parametros, List dados) throws RelatorioException {

     String caminhoRelatorio = caminhoRelatorioHTML + nomeArquivo;
     System.out.println("CAMINHO RELAT�RIO: " + caminhoRelatorio);

     File relatorio = new File(caminhoRelatorio);
     byte[] buffer = null;

     try {
         FacesContext context = FacesContext.getCurrentInstance();
         HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
         HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getResponse();

         response.setContentType("application/octet-stream");
         response.setHeader("Content-Disposition", "attachment;filename=\"" + nomeArquivo + "\"");

         if (parametros == null) {
             parametros = new HashMap();
         }

         //Neste ponto, a nossa lista preenchida com o modelo � entregue ao Jasper, que cria um DataSource com ela
         JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(dados);

         //Aqui � onde ocorre de fato o preenchimento do relat�rio, com os par�metros e DataSource passados
         JasperPrint impressao = JasperFillManager.fillReport(streamRelatorio, parametros, dataSource);

         //Ponto onde o relat�rio com os dados montados � exportado para o formato HTML
         JasperExportManager.exportReportToHtmlFile(impressao, caminhoRelatorio);

         FileInputStream fis = new FileInputStream(relatorio);
         OutputStream os = response.getOutputStream();

         response.setContentType("text/html");

         JRHtmlExporter htmlExporter = new JRHtmlExporter();

request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, impressao);
htmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, impressao);
htmlExporter.setParameter(JRExporterParameter.OUTPUT_WRITER, os);
htmlExporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/gesplan/image?image=");
htmlExporter.exportReport();

         int read = 0;
         buffer = new byte[1024];

         while ((read = fis.read(buffer)) != -1) {
             os.write(buffer, 0, read);
         }

         os.flush();
         os.close();
         fis.close();

         FacesContext.getCurrentInstance().responseComplete();

     } catch (Throwable ex) {
         ex.printStackTrace();
         throw new RelatorioException(ex);
     } finally {
         buffer = null;
     }
 }
项目:gesplan    文件:GeraRelatorioEmHTML.java   
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
    {
    String nomeDoRelatorio = (String)request.getAttribute("nomeDoRelatorio");

    System.out.println(">>>>>>>>>>>>>>>Nome do relatorio="+nomeDoRelatorio);

    List lista = (List)request.getAttribute("lista");

    HashMap<String, String> parametros = (HashMap<String, String>)request.getAttribute("parametros");

    ServletContext context = this.getServletContext();

    String nomeDoArquivoCompilado = context.getRealPath(nomeDoRelatorio);

    System.out.println(">>>>>>>>>>>>>>>>>>>> nomeDoArquivoCompilado="+nomeDoArquivoCompilado);
    File arquivo = new File(nomeDoArquivoCompilado);
    PrintWriter printWriter = response.getWriter();

    try
    {   JasperReport relatorioCompilado = (JasperReport) JRLoader.loadObject(arquivo);

        JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(lista);

        JasperPrint impressao = JasperFillManager.fillReport(relatorioCompilado, parametros, ds);

        JRHtmlExporter htmlExporter = new JRHtmlExporter();

        response.setContentType("text/html");

        request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, impressao);
        htmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, impressao);
        htmlExporter.setParameter(JRExporterParameter.OUTPUT_WRITER, printWriter);
        htmlExporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/gesplan/image?image=");
        htmlExporter.exportReport();

    }
    catch(JRException e)
    {   e.printStackTrace(printWriter);
    } 
    }
项目:konekti    文件:ReportManagerServiceImpl.java   
@Override
public ByteArrayOutputStream exportReportToHtmlStream(WebApplicationContext context, Organization organization, String code, Map<String,Object> parameters, String destFileName) throws Exception {             
    JasperPrint jasperPrint = executeReport(organization, code, parameters);

    // create the stream out report
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    // get context uri
    String uri = context.getHttpSession().getServletContext().getContextPath();

    JRHtmlExporter exporter = new JRHtmlExporter();
    String random = "" + Math.random() * 1000.0;
    random = random.replace('.', '0').replace(',', '0');    

    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, uri + "/image?r=" + random + "&image=");

    context.getHttpSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);

    exporter.exportReport();

    outputStream.flush();
    outputStream.close();

    return outputStream;
}