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


response.setContentType("text/plain");

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

0
Adwait ChitaleyAuthor Commented:
what can i use for ??

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

0
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???
0
Mick BarryJava DeveloperCommented:
you can use the runReportToHtml() method

or export manager has variety of methods for generating reports

http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperExportManager.html

theres also an example here

http://ixfree.files.wordpress.com/2007/12/reporttest.txt

0

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..



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

0
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
0
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.setHeader("Cache-Control","no-cache");
        response.setHeader("Pragma","no-cache");
        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.reset();
        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();
       
        response.setContentType("text/html");
        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=");
 
        try
        {
                exporter.exportReport();
        }
        catch (JRException e)
        {
       
        }      
        finally
        {
                if (servletoutstr != null)
                {
                        try
                        {
                                 servletoutstr.flush();
                                 servletoutstr.close();
                        }
                        catch (IOException ex)
                        {
                        }
        }
        }
  %>
   
   
   
   >
   
   
   
   
   

0
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
Java

From novice to tech pro — start learning today.