How to use Crystal report viewer in a portlet based web application

I am using JRC to view crystal reports in porlet based web application. Following is the code in JSP
<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer,
com.crystaldecisions.sdk.occa.report.application.OpenReportOptions,
com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,
com.crystaldecisions.sdk.occa.report.lib.ReportSDKExceptionBase" %>
<portlet:defineObjects />
<%
     // This sample code calls methods from the CRJavaHelper class, which
     // contains examples of how to use the BusinessObjects APIs. You are free to
     // modify and distribute the source code contained in the CRJavaHelper class.
     try {
          String reportName = "ProactiveEventsSummaryData.rpt";
          ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
          if (clientDoc == null) {
               // Report can be opened from the relative location specified in the CRConfig.xml, or the report location
               // tag can be removed to open the reports as Java resources or using an absolute path
               // (absolute path not recommended for Web applications).
               clientDoc = new ReportClientDocument();
               //clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
                              clientDoc.setReportAppServer("inproc:jrc");
               // Open report
               clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
               // Store the report document in session
               session.setAttribute(reportName, clientDoc);
          // ****** BEGIN CONNECT CRYSTALREPORTPAGEVIEWER SNIPPET **************** 
               // Create the CrystalReportViewer object
               CrystalReportViewer crystalReportPageViewer = new CrystalReportViewer();
               String reportSourceSessionKey = reportName+"ReportSource";
               Object reportSource = session.getAttribute(reportSourceSessionKey);
               if (reportSource == null)
                    reportSource = clientDoc.getReportSource();
                    session.setAttribute(reportSourceSessionKey, reportSource);
               //     set the reportsource property of the viewer
               crystalReportPageViewer.setReportSource(reportSource);
               // Apply the viewer preference attributes
               // Process the report
               crystalReportPageViewer.processHttpRequest(request, response, application, null);
          // ****** END CONNECT CRYSTALREPORTPAGEVIEWER SNIPPET ****************          
     } catch (ReportSDKExceptionBase e) {
         out.println(e);
%>
With this code , report gets displayed in the portlet but none of the actions on thre report like next page click , search button , opening subreport , clicking on drill-downs are working . The error in the explorer console is as shown below
Error: CrystalViewerCrystalEvent is not defined
javascript:CrystalViewerCrystalEvent('CrystalViewer',%20'tb=next')
PageSource of the web page shows the CrystalViewerCrystalEvent javascript function defined but for somereason its not recognized by the portlet. Has anyone worked on displaying crystalreports in a portlet ?

Code attached
<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer,
com.crystaldecisions.sdk.occa.report.application.OpenReportOptions,
com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,
com.crystaldecisions.sdk.occa.report.lib.ReportSDKExceptionBase" %>
<portlet:defineObjects />
<%
     // This sample code calls methods from the CRJavaHelper class, which
     // contains examples of how to use the BusinessObjects APIs. You are free to
     // modify and distribute the source code contained in the CRJavaHelper class.
     try {
          String reportName = "ProactiveEventsSummaryData.rpt";
          ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
          if (clientDoc == null) {
               // Report can be opened from the relative location specified in the CRConfig.xml, or the report location
               // tag can be removed to open the reports as Java resources or using an absolute path
               // (absolute path not recommended for Web applications).
               clientDoc = new ReportClientDocument();
               //clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
                              clientDoc.setReportAppServer("inproc:jrc");
               // Open report
               clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
               // Store the report document in session
               session.setAttribute(reportName, clientDoc);
          // ****** BEGIN CONNECT CRYSTALREPORTPAGEVIEWER SNIPPET **************** 
               // Create the CrystalReportViewer object
               CrystalReportViewer crystalReportPageViewer = new CrystalReportViewer();
               String reportSourceSessionKey = reportName+"ReportSource";
               Object reportSource = session.getAttribute(reportSourceSessionKey);
               if (reportSource == null)
                    reportSource = clientDoc.getReportSource();
                    session.setAttribute(reportSourceSessionKey, reportSource);
               //     set the reportsource property of the viewer
               crystalReportPageViewer.setReportSource(reportSource);
               // Apply the viewer preference attributes
               // Process the report
               crystalReportPageViewer.processHttpRequest(request, response, application, null);
          // ****** END CONNECT CRYSTALREPORTPAGEVIEWER SNIPPET ****************          
     } catch (ReportSDKExceptionBase e) {
         out.println(e);
%>
Edited by: teethoma on Nov 30, 2009 10:06 AM

Similar Messages

  • Crystal Reports Viewer Control  - Visual Studio 2008 WEB Application

    My question is this:  Has ANYONE on this planet been able to get the ASP .NET CR Viewer control to actually work?
    Why does this editor NOT recognize End-of-line or CR characters or any whitespace??
    I have developed a Crystal Reports "Viewer" web application in VS2008 using C#.
    It's a simple app, in that it's a single page with a treeview control (containing the grouped names of the reports to which the user has access) and the CR Viewer control.
    The report files live on a network share, and permissions to them is controlled via a SQL Server database, which, for each report, stores the UserID and Logion for the oracle database, as well as any required parameter values.
    The reports themselves are all hititng an Oracle 10g database.
    I managed to do this in a Windows desktop applcation using Visual Studio 2005 and VB .net, but now, upon trying to make this a web application in VS2008, I have completely failed. The application works when run locally, but when deployed to the web server, I experience database login prompts when I should not, (the dreaded "Report requires further information" message) even thought the setdatabaselogin has already been set. I have tried saving the reportdocument in viewstate and re-assigning the viewer Datasource property to it, that also fails. However, it only does it on some reports, and not others. (admittedly, the reports may have been created using different CR versions)
    The viewer also displays data it should not be displaying when I attempt to scroll, when I do manage to get a report to run.
    I am setting parameters dynamically at run time, whose values are stored in the SQL database.
    Code Sample:
    protected void ShowReport(int ReportID)
            SQLDataPortal2005.Common sql = new SQLDataPortal2005.Common();
            Hashtable outParms = new Hashtable();
            string sAccess;
            IDataReader dr;
            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
            sAccess = p.Identity.Name;
            int j = 0;
            int i = -1;
            if (!IsAdmin())
                sql.ExecNonQuery("CrystalReports", outParms, "proc_CRM_Check_Permissions", sAccess, Convert.ToInt32(TreeView1.SelectedNode.Value));
                if (outParms["@Allow"].ToString() != "True")
                   Response.Redirect("ErrorPage.aspx");  // redirect to  error page
            string sPath = System.Configuration.ConfigurationManager.AppSettings["WareHouse"].ToString();
            sPath = sPath + TreeView1.SelectedNode.Text.Trim() + ".rpt";      
            rptDocument.Load(sPath);
            dr = sql.GetDataReader("CrystalReports", "proc_CRM_Get_Report", Convert.ToInt32(TreeView1.SelectedNode.Value));
            while (dr.Read() == true)
                j += 1;
                if (j < 2)
                    rptDocument.SetDatabaseLogon(dr["DB_Login"].ToString(), dr["DB_Pwd"].ToString(), "PLAW", "LAWDB", true);
                    pList = dr["ParmList"].ToString().Split(',');
            dr.Close();
            dr.Dispose();
            if (pList.Length > 0 && pList[0].ToString().Trim() != "")
                foreach (CrystalDecisions.Shared.ParameterField x in rptDocument.ParameterFields)
                    i++;
                    switch (x.ParameterValueType)
                        case CrystalDecisions.Shared.ParameterValueKind.BooleanParameter:
                            rptDocument.SetParameterValue(x.Name, Convert.ToBoolean(pList<i>));
                            break;
                        case CrystalDecisions.Shared.ParameterValueKind.CurrencyParameter:
                            rptDocument.SetParameterValue(x.Name, Convert.ToDouble(pList<i>));
                            break;
                        case CrystalDecisions.Shared.ParameterValueKind.DateParameter:
                            rptDocument.SetParameterValue(x.Name, Convert.ToDateTime(pList<i>));
                            break;
                        case CrystalDecisions.Shared.ParameterValueKind.DateTimeParameter:
                            rptDocument.SetParameterValue(x.Name, Convert.ToDateTime(pList<i>));
                            break;
                        case CrystalDecisions.Shared.ParameterValueKind.NumberParameter:
                            rptDocument.SetParameterValue(x.Name, Convert.ToInt32(pList<i>));
                            break;
                        case CrystalDecisions.Shared.ParameterValueKind.StringParameter:
                            rptDocument.SetParameterValue(x.Name, Convert.ToString(pList<i>));
                            break;
                        case CrystalDecisions.Shared.ParameterValueKind.TimeParameter:
                            rptDocument.SetParameterValue(x.Name, Convert.ToDateTime(pList<i>));
                            break;
            Session["CReport"] = rptDocument;
            CRV1.ReportSource = rptDocument;
            CRV1.DisplayGroupTree = false;
            CRV1.HasRefreshButton = true;
            CRV1.ShowFirstPage();
    Is there a better/different way of accomplishing this very simply process? All I need this application to do is to view a report, while setting it's parmeters (if required) dynamically at run time. I don't EVER want the user to be prompted for DB LOGIN INFO.
    Edited by: RichardK on May 10, 2010 4:14 PM
    Edited by: RichardK on May 10, 2010 4:14 PM
    Edited by: RichardK on May 10, 2010 4:16 PM
    Edited by: RichardK on May 10, 2010 4:18 PM
    Edited by: RichardK on May 10, 2010 4:22 PM
    Edited by: RichardK on May 10, 2010 4:23 PM

    To answer you question; Yes, I suspect that most of the users in this community have managed to successfully create web apps. And this is the tiniest of sampling of the developers out there...
    A few suggestions;
    1) Keep the posts to under 1200 characters. Otherwise, the formatting is lost which makes it difficult to read.
    2) Try out a few sample apps from here:
    https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
    Suggest; csharp_web_simplelogonengine.zip, csharp_web_simplelogonviewer.zip and csharp_web_subreport_logon.zip.
    3) Start simple; one table, one field, no subreports. Hard code the database logon parameters. Convince your self that this does work. Increase the complexity - add fields, tables, subreports. Do not mix connection methods (e.g.; if ODBC for main, than ODBC for sub is a good idea, though not a requirement).
    4) See the article [Troubleshooting Guide to Database Connectivity Issues with Crystal Reports in Visual Studio .NET Applications|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0225775-88c4-2c10-bd80-8298769293de].
    5) See  [this|http://www.sdn.sap.com/irj/boc/go/portal/prtroot/docs/library/uuid/d05b3bb7-0f28-2c10-4ea3-84dbdc4e414e?quicklink=index&overridelayout=true] article.
    6) Consider creating a phone case here:
    http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryID=11522300
    Ludek
    Follow us on Twitter
    http://twitter.com/SAPCRNetSup

  • Problem on using Crystal Report Viewer on windows application ("specified type is not valid ")

    Hi
    I am having problem on using Crystal Report Viewer on one of my windows application.
    I am not sure how to put the Crystal Report Viewer 11 Control onto the tool box.
    I could found a Crystal Report Viewer control on my computer, but it is version 8.5.
    I have also found another one which is Called Crytal ActiveX Report Viewer, i don't think it is the one I can use. As when I try to load a dummy report on to the Crytal ActiveX Report Viewer, It return an error. "specified type is not valid"
    Please see the Code sample below.
    private sub loadReport()
         Dim r as New ReportDocument
         'v is the name of the Crystal ActiveX Report Viewer Control
         r.Load("C:\Report1.rtp")
         v.ReportSource(r) <---It throw error on this line.
    End Sub
    Could you give me some advice about what have I done wrong, How to check if I have set up the Crystal Report Component correctly in my Visual Studio 2005 Standard edition.
    Thanks in advances.
    Many thanks
    Chi

    VS 2005 Standard and Express editions do not come with Crystal Reports; only the Professional and higher editions will have CR bundled. However, I believe you can purchase CR XI R2 Developer and it will give you the components you need to create a VS .NET 2005 application using the Standard edition.
    -MJ

  • How to use crystal report in php

    hello
    i need help for how to use crystal report for view the database report spacilly crosstab report i need it very much to complete my project ill be very thank full for help
    from farooq

    Hello sir
    i am sudeep and i need to deploy crstal reports in php
    i want to integrate it in sugar crm (open source project(
    can u plz tell me how to do it
    i have written this code
    <?php
    //echo phpinfo();exit;
    $ObjectFactory= New COM("CrystalReports11.ObjectFactory.1");
    $crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");
    //$crapp = new COM("CrystalRuntime.Application.10");
    $reportToRun="C:\Report4.rpt";
    $creport = $crapp->OpenReport($reportToRun, 1);
    //reportToRun=full path to *.rpt file
    $creport->Database->Tables->
    Item(1)->ConnectionProperties['User ID'] = $user;
    $creport->Database->Tables->
    Item(1)->ConnectionProperties['Password'] = $pass;
    //fomatType = integer 22=xls, 31=pdf etc
    $creport->ExportOptions->FormatType = $formatType;
    //type 1 is to output to a file I think 2 is email
    $creport->ExportOptions->DestinationType = 1;
    //location = full path to report output file
    $creport->ExportOptions->DiskFileName = $location;
    $creport->DiscardSavedData();
    $creport->Export(False);
    ?>
    thanks in advance

  • How to use Crystal Reports XI release 2 Preview with Lotus Notes  Scripts ?

    <br />Hi all,<br /><br /> How to use Crystal Reports XI release 2 Preview with Lotus Notes 7 Scripts ?<br /><br /> <br /><br />Thank&#39;s  <br />

    Hi,
    we are using Lotus Notes and Crystal Reports for preview and printing reports from our Lotus Notes Applications. We use the RDC object model. For previewing the reports we export them in an pdf-file and then start the PDF Reader to show the Preview. This works fine.
    But with Crystal Reports > 11 the RDC Object Model is no longer supportet, so we look for another way to preview and print our reports.
    I try to preview a report build with crystal report XI release 2 in my thick client (Lotus Notes) using java reporting component JRC, this report uses an native xml file as datasource. If the datasource is saved with the report everything works fine, but otherwise I have the following error:
    JRCAgent1 detected an exception: javax.xml.namespace.QName: method getPrefix()Ljava/lang/String; not found
    I also tried the .jars from Crystal4Eclipse. Doesn't work. When I use Eclipse to view the report everything works fine. The class QName exitsts in the jaxrpc.jar and in the xbean.jar, but only in the xbean.jar a Methode getPrefix exists.
    This is what we tried:
    Works fine with RDC. Doesn't work with JRC until now.
    Did this help you ?
    Perhaps you con help me with the JRC, because I'm a java newbee so any ideas could be helpful.
    Oliver
    <p><a href="http://www.cominform.de">www.cominform.de</a></p>

  • How to use Crystal Report in Oraacle Jdeveloper

    Hi all,
    I am new in crystal report . i want information how to use Crystal Report in Oraacle Jdeveloper10g like how to call .rpt file in oracle Jdeveloper or how to compile .rpt file in crystal report
    plz  can any one help me regarding that matter
    -Amol

    Hello Amol,
    The Crystal Report for Eclipse - Java-based Crystal Reports development - is integrated into the Eclipse IDE and IBM RAD.
    However, it's not integrated with JDeveloper.
    You can still access the Crystal Java Reporting Component to create Java applications to view Crystal Reports, but you'd not be able to create RPT files unless you use Eclipse or RAD.
    More info for CR4E here:
    [https://boc.sdn.sap.com/creclipse|https://boc.sdn.sap.com/creclipse]
    Sincerely,
    Ted Ueda

  • How to use crystal report in J2EE Project.

    how to use crystal report in J2EE Project.. any one know please inform me...
    thank you..

    http://www.inetsoftware.de/products/crystalclear/Crystal-Reports.htm?adwords=googleCrystal&gclid=CKDD1YDem5UCFRpknAodZA4EhA
    I think this might help u...

  • How to use Crystal Reports 11 with Visual C++ 2005 ?

    Post Author: compvis
    CA Forum: General
    Hello everyone !
    Plz tell me how to use Crystal Reports XI with Visual C++ 2005 ?
    Thank you so much !

    Moved to .NET SDK forum.
    Need more info, version of the assemblies you are using and the assembly file system version number ( not the same as what you see in the properties of the project.
    As well, what happens if you use OLE DB as a test?
    Thank you
    Don

  • How to use crystal reports in LabVIEW

    Hi, Can anybody tell me how t use crystal reports in LabVIEW. If any material if you will be very helpful.
    Regards,
    Rajashekar

    activeX

  • How to use crystal report with php

    Hello every body
    can any body know how to use crystal report with php any helping material, code or tutorial for my problem ill be very thankful for helping me
    farooq

    Hello sir
    i am sudeep and i need to deploy crstal reports in php
    i want to integrate it in sugar crm (open source project(
    can u plz tell me how to do it
    i have written this code
    <?php
    //echo phpinfo();exit;
    $ObjectFactory= New COM("CrystalReports11.ObjectFactory.1");
    $crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");
    //$crapp = new COM("CrystalRuntime.Application.10");
    $reportToRun="C:\Report4.rpt";
    $creport = $crapp->OpenReport($reportToRun, 1);
    //reportToRun=full path to *.rpt file
    $creport->Database->Tables->
    Item(1)->ConnectionProperties['User ID'] = $user;
    $creport->Database->Tables->
    Item(1)->ConnectionProperties['Password'] = $pass;
    //fomatType = integer 22=xls, 31=pdf etc
    $creport->ExportOptions->FormatType = $formatType;
    //type 1 is to output to a file I think 2 is email
    $creport->ExportOptions->DestinationType = 1;
    //location = full path to report output file
    $creport->ExportOptions->DiskFileName = $location;
    $creport->DiscardSavedData();
    $creport->Export(False);
    ?>
    thanks in advance

  • How to use crystal report 2013 in delphi 6?

    i want to use crystal report in delphi 6,including sso and the way to use opendocument in delphi 6 ?please tell me the step, thanks advanced!
    by the way ,my crystal reports version is 2013.

    You posted the same question here:
    how to use crystal report in delphi 6?
    And I answered you there. Not sure why create another discussion? Please, if you have more questions on "How to in Delphi", continue on the other thread as I will lock this one.
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • How to use Crystal Reports XI in SBO 2004 ?

    Hello,
    I´m making an Add-on in VB .Net and need to show a report from Crystal Reports XI (a .rpt file). My Add-on is a Console Application. From what i have read from this forum the best way is to use a Windows Form (not a form from SBO) with a "Crystal Report Viewer". How is this done exactly?
       1 - What refences to include in the project?
       2 - How to assign to Crystal Report Viewer to the Windows Form?
       3 - How do i change in VB .Net code (that is, in runtime) the datasource from the .rpt file?
    Can you please give a code example.
    Thank You.
    Jorge Lopes

    Thanks Ibai.
    My code to change DataSource is:
    Try
                    Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
                    rpt.Load(strPath & RELATORIO_ORCAMENTO)
                    '/ Inicio
                    Dim rptTableLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo
                    Dim rptConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
                    Dim rptTables As CrystalDecisions.CrystalReports.Engine.Tables = Nothing
                    Dim rptTable As CrystalDecisions.CrystalReports.Engine.Table = Nothing
                    With rptConnectionInfo
                        .ServerName = ODBC_DATASOURCE
                        .DatabaseName = objCompany.CompanyDB
                        .UserID = System.Windows.Forms.SystemInformation.UserName
                    End With
                    rptTables = rpt.Database.Tables
                    For Each rptTable In rptTables
                        rptTableLogonInfo = rptTable.LogOnInfo
                        rptTableLogonInfo.ConnectionInfo = rptConnectionInfo
                        rptTable.ApplyLogOnInfo(rptTableLogonInfo)
                        rptTable.Location = rptTable.Location
                    Next
                    If (rpt.Subreports.Count > 0) Then
                        ActualizaSubReports(rpt.Subreports, rptConnectionInfo)
                    End If
                    '/ Fim
                    rpt.SaveAs(rpt.FileName)
                    rpt.Close()
                Catch ex As Exception
                    objApplication.MessageBox(ex.Message)
                End Try
    Jorge Lopes

  • I couldn't use Crystal Report Viewer Control in my ASPX page.

    Please I'm having a problem with crystal report viewer control which I couldn't resolve. I'm using VS 2008 and Framework 3.5.
    I building an ASP web application and when I add a CrystalReportViewer to my ASPX page I'm getting the following
    error.
    "Error     20     Type 'CrystalDecisions.Web.CrystalReportViewer' is not defined."
    I think maybe because I'm not having the right reference file. I'm using Crystal Reports 2008 and also I installed the following
    Service Packs:
    cr121_redist_install
    CR2008-SP1
    CR2008SP1-Fixes 1 and 2
    cr121_clickonce
    I check all the reference files in my project and they are as follow:
    CrystalDecisions.CrystalReports.Engine  (12.0.2000.0)
    C:\Program Files\Business Objects\Common\4.0\managed\dotnet2\CrystalDecisions.CrystalReports.Engine.dll
    CrystalDecisions.Enterprise.Framework  (12.0.1100.0)
    C:\Program Files\Business Objects\Common\4.0\managed\CrystalDecisions.Enterprise.Framework.dll
    C:\Program Files\Business Objects\Common\4.0\managed\CrystalDecisions.Enterprise.InfoStore.dll  (12.0.1100.0)
    C:\Program Files\Business Objects\Common\4.0\managed\dotnet2\CrystalDecisions.ReportSource.dll  (12.0.2000.0)
    C:\Program Files\Business Objects\Common\4.0\managed\dotnet2\CrystalDecisions.Shared.dll  (12.0.2000.0)
    Please Why I'm getting this problem? How I can resolve it?
    Thanks.

    If you have a viewer on one of your forms, delete it off the form and re-add it, ensuring that the crystalreports.web assembly referenced in your project is version 12.
    Ludek

  • How to use Crystal Report in JDeveloper

    Hi all,
    I'm a JDeveloper fresher. To day, i want to use Crystal Report 2008 in JDeveloper.
    Please support to me: how to setup, config Crystal Report to use with JDeveloper.
    share to me your demo if you have.
    Thanks!

    No, I don't have example (I usually work with Crystal Reports inside MS Visual Studio and C#)
    But some very basic example would be:
    1. Create rpt file in Crystal Report Designer
    2. Download CR Java Runtime files from here: SAP Crystal Reports, version for Eclipse - Down... | SCN
    3. Add necessary jar files from previous step to your jdev project
    4. Create new java servlet and map to some url (for example: /reports)
    5. Add button/link to invoke this servlet, for example <a href="reports" target="_blank">click here</a>
    6. Inside your servlet add code similar to this:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ReportClientDocument reportClientDoc = new ReportClientDocument();
        try {
            reportClientDoc.open("Path to your report file", 0);
    // for example, to output pdf file
    response.setContentType("application/pdf");
            reportClientDoc.getPrintOutputController().export(ReportExportFormat.PDF, response.getOutputStream());
        } catch (Exception e) {
            e.printStackTrace();
    If you want to use Crystal Reports JSF Viewer then you need to copy "crystalreportviewers" folder from downloaded CR Java Runtime to public_html location inside your app
    and adjust code in servlet:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ReportClientDocument reportClientDoc = new ReportClientDocument();
        try {
            reportClientDoc.open("Path to your report file", 0);
            Object reportSource = reportClientDoc.getReportSource();
            CrystalReportViewer viewer = new CrystalReportViewer();
            viewer.setOwnPage(true);
            viewer.setReportSource(reportSource);
            viewer.setPrintMode(CrPrintMode.PDF);
            viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), response.getWriter());
        } catch (Exception e) {
            e.printStackTrace();
    Of course, you can embed this viewer in existing page(instead of opening in new page/tab)
    Dario

  • How to use Crystal Report with Java - need help

    Dear everyone,
    i am completely new to Crystal report , please can anyone help me to creat a very simple Report using the Crystal report,
    the report will show some records from oracle DB.
    How can i make it by a simple example and with code please?
    do i need any JAR or Bean for Crystal report?
    thanks for your help and please don't hesitate to contact me in case of any inquiries.
    my email: [email protected]
    Thanks in advance

    I what to use Crystal report to generate report.My programe in java swing .Iam retrive table from database in Jtable .But when giving print
    command its print half screen .so that why I wantto usecrystal report
    package file2;
    import file2.choice;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    import java.util.*;
    import java.awt.print.*;
    import javax.swing.table.*;
    import com.sun.java.swing.*;
    import javax.swing.JTable;
    public class cour extends JFrame implements Printable
         //Menu fileMenu;
         public static void main(String[] a)
    cour n = new cour();
    n.setVisible(true);
    public cour()
         super("Course Report");
         report();
         protected void report()
              JPanel panel = new JPanel();
         JButton printButton = new JButton("Print");
         panel.add(printButton);
         JButton exitButton = new JButton("Exit");
         panel.add(exitButton);     
         DefaultTableModel defaulttablemodel = new DefaultTableModel();
              JTable jtable = new JTable(defaulttablemodel);
              panel.add(new JScrollPane(jtable));
              String      tempname="";
              int tempcnt;
              String driver="sun.jdbc.odbc.JdbcOdbcDriver";
              String url="jdbc:odbc:regs";
              Object[] data = new Object[4];
              try
                             Class.forName(driver);                         
                             Connection connection=DriverManager.getConnection(url,"sa","");
                             Statement statement = connection.createStatement();     
                             String query = "SELECT courseid as CourseID,coursen as CourseName,cfee as Fee,coursed as Duration FROM course";
                             ResultSet rs = statement.executeQuery(query);     
                             ResultSetMetaData rmeta = rs.getMetaData();
                             int numColumns=rmeta.getColumnCount();                         
                             for(int i=1;i<=numColumns;i++)
                                  if(i<=numColumns)
                                       defaulttablemodel.addColumn(rmeta.getColumnName(i));
                             while(rs.next())
                                  for(int i=1;i<=numColumns;++i)
                                       if( i<=numColumns)
                                            tempname = rs.getString(i);
                                            tempcnt=i-1;
                                            data[tempcnt] = tempname;          
                                  defaulttablemodel.addRow(data);                              
                   catch(Exception ex)
              printButton.addActionListener(new ActionListener()
         public void actionPerformed(ActionEvent ae)
              /*if(ae.getActionCommand().equals("Print"))
              PrinterJob pj = PrinterJob.getPrinterJob();
              pj.setPrintable(cour.this);
              if (pj.printDialog())
              try
              pj.print();
              catch (PrinterException pe)
              System.out.println(pe);
    exitButton.addActionListener(new ActionListener()
         public void actionPerformed(ActionEvent ae)
              choice ch=new choice();
                   setVisible(false);
                   ch.setVisible(true);
    setContentPane(panel);
         setSize(1040,780);
    /*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = getSize();
    int x = (screenSize.width - frameSize.width) / 2;
    int y = (screenSize.height - frameSize.height) / 2;
    setLocation(x, y);*/
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    public int print(Graphics g, PageFormat pf, int pageIndex)
    if (pageIndex != 0) return NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D)g;
    g2.translate(pf.getImageableX(), pf.getImageableY());
    getContentPane().paint(g2);
    return PAGE_EXISTS;
    }

Maybe you are looking for

  • Invalid stream header Exception - AES PBE with SealedObject

    I am trying to do an PBE encryption with AES algorithm and SunJCE provider, using the SealedObject class to encrypt/decrypt the data... And Im still getting the "invalid stream header" exception. Ive searched this forum, readed lots of posts, example

  • Is it possible to buy macbook air with russian keyboard?

    Is it possible to buy macbook air with russian keyboard?

  • Camera Raw update in Elements 11

    Camera Raw update in Elements 11 I have installed Camera Raw 8.3 in Elements 11 to use RAW files from Canon EOS 70D However when checking the about in Elements 11 it still says installed version is 7.4 and it will not open RAW files from camera.

  • BI Content Cube 0PUR_C01 & PO Item Cancellations

    Hi, InfoCube 0PUR_C01 has two seperate ways: 1. Conventional way:2LIS_02_S012 2. The New Way: 2LIS_02_SCL and 2LIS_02_ITM I need to see the PO Item Cancellations, which of the 2 ways would be the best for that? Thanks

  • Styling text to underline on hover in flex 4

    I'm sure there's an incredibly easy way to do this, but I've been searching for a while now and haven't turned it up. What I want to to is have a bunch of label components throughout my application that will change their text style to underline on ho