Example 2 - Export a Report with Logon

The following example is a simple JSP page that demonstrates how to use the export control to export the first three pages of a report to RTF.

Note:    The report used in this example is not included with the tutorials.

ExportWithLogonSample.jsp

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<%@page import="com.crystaldecisions.reports.sdk.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.reportsource.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.data.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>

<%@page import="com.crystaldecisions.report.web.viewer.*"%>

<%

String reportName = "/CRXI_JRC_ExportWithLogon.rpt";

String userName = "devtech";

String password = "devtech";

ReportClientDocument oReportClientDocument = new ReportClientDocument();

try

{

    oReportClientDocument.open(reportName , 0);

    IReportSource oReportSource = (IReportSource)oReportClientDocument.getReportSource();

            

    ConnectionInfos oConnectionInfos = new ConnectionInfos();

    ConnectionInfo oConnectionInfo = new ConnectionInfo();

    

    oConnectionInfo.setUserName(userName);

    oConnectionInfo.setPassword(password);

    

    oConnectionInfos.add(oConnectionInfo);

    

    ExportOptions oExportOptions = new ExportOptions();

    //oExportOptions.setExportFormatType(ReportExportFormat.RTF);    

    //oExportOptions.setExportFormatType(ReportExportFormat.crystalReports);    

    oExportOptions.setExportFormatType(ReportExportFormat.PDF);        

    

    ReportExportControl oReportExportControl = new ReportExportControl();

    oReportExportControl.setReportSource(oReportSource);

    oReportExportControl.setExportOptions(oExportOptions);

    

    oReportExportControl.setExportAsAttachment(true);

    

    oReportExportControl.setDatabaseLogonInfos(oConnectionInfos);

    

    oReportExportControl.processHttpRequest(request, response, getServletConfig().getServletContext(), null);

}

catch(ReportSDKException e)

{

    out.print(e);

}    

%>



Business Objects
http://www.businessobjects.com/
Support services
http://www.businessobjects.com/services/support/