Jasper HTML

hi experts i have a problem in my code for generating pdf

 JasperRunManager.runReportToPdfStream(reportStream,servletOutputStream,new HashMap(), resultSetDataSource);

when This line is executed the content of database shows in pdf format on browser

but i want ro show the plain text on browser..
i did the following changes


JasperRunManager.runReportToHtmlFile(jasperReport,new HashMap(), resultSetDataSource);

but it saves the html file in plain text format in my project folder..
but i want to show on  broswer  how can i do????
Adwait ChitaleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
runReportToPdfStream() produces pdf data, you need to use something different to generate a plain text report

Adwait ChitaleyAuthor Commented:
what can i use for ??

Mick BarryJava DeveloperCommented:
did you want a plain text report or html report?

PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Adwait ChitaleyAuthor Commented:
i want both ..

how can i do???
Mick BarryJava DeveloperCommented:
you can use the runReportToHtml() method

or export manager has variety of methods for generating reports


theres also an example here



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Adwait ChitaleyAuthor Commented:
the above line  store the report in html file in my  project ..

nut i want to show the html file report on browser when i submit the form i dont want to store in my project i just want  to show on browser in plain or html format..

Mick BarryJava DeveloperCommented:
the example at the bottom shows streaming html

Adwait ChitaleyAuthor Commented:
sorry i didnt get please explain again in breif

i just want to show the data on browser in html or text format
Mick BarryJava DeveloperCommented:
<%@page import="javax.servlet.ServletOutputStream"%>
<%@page import="javax.servlet.http.HttpServletResponse"%>
<%@page import="java.io.ByteArrayOutputStream"%>
<%@page import="java.util.*"%>
<%@page import="net.sf.jasperreports.engine.data.*"%>
<%@page import="net.sf.jasperreports.engine.export.*"%>
<%@page import="net.sf.jasperreports.engine.design.*"%>
<%@page import="net.sf.jasperreports.engine.*"%>
<%@page import="net.sf.jasperreports.view.*"%>
<%@page import="java.io.*"%>

        response.setDateHeader ("Expires", 0);
        BeanArray[] ReportResult = (BeanArray[])objDispatcher.getContextValueObj("REPORT");
      // or which ever way we can get the bean array

        JasperPrint jp=null;
        JasperReport jr = null;
        File reportFile = new File(application.getRealPath("0/htm/BeanTest.jasper"));
        String spath = reportFile.getAbsolutePath();
        InputStream inputstream = new FileInputStream(spath);
        JRDataSource jrdatasource = new JRBeanArrayDataSource(ReportResult);
        Map parameters = new HashMap();
        jp = JasperFillManager.fillReport(inputstream, parameters,jrdatasource);
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        JRExporter exporter = null;
        ServletOutputStream servletoutstr = response.getOutputStream();
        exporter = new JRHtmlExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, servletoutstr);
        Map imagesMap = new HashMap();
        request.getSession().setAttribute("IMAGES_MAP", imagesMap);
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image.jsp?image=");
        catch (JRException e)
                if (servletoutstr != null)
                        catch (IOException ex)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.