Example 1 - Set Database Logon

The following example is a JSP page that demonstrates how to set the database logon information for a report. After the logon information has been set, the report is displayed.

Note:    For any report used with this tutorial sample, you must have the appropriate JDBC data source configured so that it can be accessed by your application server. The report used in this example is not included with the tutorials.

setDbLogonViewReport.jsp

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

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

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

<%

    Object reportSource = session.getAttribute("reportSource");

    if (reportSource == null)

    {

       String report = "/reports/sample.rpt";

       ReportClientDocument reportClientDoc = new ReportClientDocument();

       reportClientDoc.open(report, 0);

       reportSource = reportClientDoc.getReportSource();

       session.setAttribute("reportSource", reportSource);

    }

    

    ConnectionInfos connInfos = new ConnectionInfos();

       IConnectionInfo connInfo1 = new ConnectionInfo();

    connInfo1.setUserName("guest");

    connInfo1.setPassword("password");

    connInfos.add(connInfo1);

    CrystalReportViewer viewer = new CrystalReportViewer();

    viewer.setReportSource(reportSource);

       viewer.setEnableLogonPrompt(false);  

    viewer.setDatabaseLogonInfos(connInfos);

    

    if (session.getAttribute("refreshed") == null)

    {

    viewer.refresh();

    session.setAttribute("refreshed", "true");

    }

    

    viewer.setOwnPage(true);

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

%>



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