### API demos

Here is a list of the JReport Server demo programs.

- Programs in `<install_root>\help\samples\APICluster`:
  - DemoLoadBalancer.java
    Demo to implement the jet.server.api.cluster.LoadBalancer for randomly selecting a clustered server. For details, see Balancing the server load.
  - DemoRemoteDispatcher.java
    An example of dispatching request to remote clustered server according to Round-Robin algorithm. For details, see Dispatching RMI Server Pages requests in multiple server environment.
- Programs in `<install_root>\help\samples\APIParameter`:
  - DemoParameterGenerator.java
    An example of implementing the jet.server.api.custom.schedule.ParameterGenerator for setting dynamic parameter values. For details, see Setting dynamic parameter values when running/scheduling report via API.
- Programs in `<install_root>\help\samples\APISecurity`:
  - CustomizedSendFileAuthorizor.java
    Demonstrates implementation of SendFileAuthorizor, which is used to control users' accessibility to certain files in server machine when they access the server via http.
  - DemoAuthenticationProvider.java
    Demo for implementation of the jet.server.api.custom.security.AuthenticationProvider interface. For details, see Customized implementation of the Security API.
  - DemoAuthorizationProvider.java
    Demo for implementation of the jet.server.api.custom.security.AuthorizationProvider interface. For details, see Customized implementation of the Security API.
- Programs in `<install_root>\help\samples\APISecurity\AddPrincipal`:
  - AddGroup.java
    An example of creating groups and getting the current information of group.
  - AddRole.java
    An example of creating roles and getting the current information of role.
  - AddUser.java
    An example of creating users and getting the current information of user.
  - SecurityGroupCover.java
    An example of creating groups and configuring other security settings.
  - SecurityRoleCover.java
    An example of creating roles and configuring other security settings.
  - SecurityUserCover.java
    An example of creating users and configuring other security settings.
- Programs in `<install_root>\help\samples\APISecurity\LoginLogout`:
  This folder holds JSP source files that experiment with how the two versions of checkLogin() work. The files provide a way to access pages protected by checkLogin() by doing various forms of login to see how the process works. After doing a login, the user can do a logout, in order to establish the same initial state to try another scenario.

  The experiments relate to accessing files that are protected by a call to one of the checkLogin() mehtods which validates that a user is logged into the session or logs a user into the session based on the current HTTP Request.

  Comments in the entry point page, loginIndex.jsp, describe how the files work and how to deploy them for use.

  - loginIndex.jsp
    Main entry point for the group of JSP files. This is the dispatcher and home page for the group.
  - loginDoCheckLogin.jsp
    This does the work to run the right JSP page that matches the scenario chosen by the user in loginIndex.jsp.
  - loginUtilCheckLogin.jsp
    This is the page that is protected by a call to HttpUtil.checkLogin(). After checkLogin() allows it to run, it reports on how it was run and what happened to allow it.
  - loginSessionCheckLogin.jsp
    This is the page that is protected by a call to HttpUserSessionManager.checkLogin(). After checkLogin() allows it to run, it reports on how it was run and what happened to allow it.
  - loginTunOnSSO.jsp
    This is a helper page to register that the ExternalAuthorized package com.example.MyExternalAuthorized is to be used by JReport Server. This turns on the Single Sign On functionality. This page is only useful (and is only given as a choice by loginIndex.jsp) when the com.exmple.MyExternalAuthorized package is deployed and findable on the class path. Read the comments in the source to the package found in the SingleSignOn folder next to this one.
  - loginTunOffSSO.jsp
    This is a helper page to unset the ExternalAuthorized that is currently set in the server. This turns off the Single Sign On functionality.
  - loginLogout.jsp
    This is a helper page that logs out a user from the session in order to have a standard starting state.
- Programs in `<install_root>\help\samples\APISecurity\SingleSignOn`:
  This folder holds sample source files that show examples of implementing a Single Sign On system to allow an existing application and JReport Server to co-operate with logging in users while running on the same web server.

  There are two example implementations of the HttpExternalAuthorized java interface. These implementations provide the Single Sign On functionality. Each file has comments inside that give directions on how to install and use them.

  - CustomHttpExternalAuthorized.java
    Implementation of HttpExternalAuthorized to load when JReport Server starts up.
  - com\example\MyExternalAuthorized.java
    Implementation of HttpExternalAuthorized written as a package to load on demand while JReport Server is running.

  One file is the source for a servlet that can be used to dynamically set which instance of an HttpExternalAuthorized is used by JReport Server. This would be compiled and deployed using local technique for deploying a servlet.

  - CustomServlet.java
    Demo to set implementation of HttpExternalAuthorized into the report server.

  The rest of the files in the folder are JSP files that can be placed into the web server to run through several scenarios that show how an application and JReport Server JSP pages can co-operate to manage user logins within a Single Sign On system. Each file has comments inside that explain what it does and how it fits into the demonstration. These JSP files can be copied to the folder `public_html\jinfonet` where they can be run with a standard install of JReport Server.

  - customIndex.jsp
    Entry point JSP page for the demo, to run through the various scenarios that show how Single Sign On behaves. This page includes operations for logging out, to recreate the state of a user not being logged in. It also has controls for turning on and off the Single Sign On functionality.
  - customViewReport.jsp
    This is the requested report used in the demo to show how Single Sign On supports authentication for it. It runs a simple report which is displayed in the browser.
  - customNoAuth.jsp
    Runs the scenario where nothing special is done in the run-report request to authenticate the user.
  - customParamAuth.jsp
    Runs the scenario where the User ID is passed in via a query parameter in the run-report request as a way to authenticate the user.
  - customSessionAuth.jsp
    Runs the scenario where the User ID is put into the servlet session variable emulating how the application login would do this, as a way to authenticate the user.
  - customTurnOnSSO.jsp
    Helper page that sets the instance of the HttpExternalAuthroized class registered with JReport Server, to turn on the Single Sign On functionality.
  - customTurnOffSSO.jsp
    Helper page that unsets the instance of the HttpExternalAuthroized class registered with JReport Server, to turn off the Single Sign On functionality.
- Programs in `<install_root>\help\samples\APIServer`:
  - APIDemoDeployRpt.java
    An example of publishing catalogs, reports, or folders to the server.
  - APIDemoDynamicExportTask.java
    An example of scheduling a customized task. For details, see Scheduling a customized task using User Task.
  - APIDemoPublishRpt.java
    An example of publishing a scheduled task.
  - APIDemoReportEngine.java
    An example of using the ReportEngine to run a report, export/print a report, and set the where portion.
  - APIDemoRunAndExportReport.java
    An example of exporting a report to some formats, and then saving them to local disk.
  - APIDemoRunReport.java
    An example of running a report.
  - APIDemoRunReportWithTimeout.java
    An example of running reports with timeout.
  - APIDemoSendEMail.java
    An example of publishing a report to e-mail.
  - DemoTrigger.java
    This demo creates a trigger, submit a schedule bound with the trigger, then fire the trigger to run the schedule.
  - ViewHtmlPipelineServlet.java
    This is a servlet demo of viewing report as HTML pipeline format.
- Programs in `<install_root>\help\samples\APITaskListener`:
  - TestTaskListener.java
    An example to demonstrate how to implement users' own scripts before and after task running and how to get the information about a task. For details, see Adding TaskListener.
- Programs in `<install_root>\help\samples\JSPSamples`:
  - ApplyUserCSS
    An example of applying user defined CSS to the HTML report result. For details, see Applying a user defined CSS to HTML result file.
  - DHTMLRunAndExport
    An example of using JSP to build URL to run a report in JReport Desktop Viewer Bean. After copying the contents of the folder (demo) to where JSP can be run, for example, `<install_root>\public_html`, you can run the demo using the URL `http://localhost:8888/demo/main.jsp`.
  - OpenMultipleReports
    Demo JSPs for opening multiple reports in one session. For details, see Opening multiple reports in one session.
  - PrintReport
    These JSP files show how to print reports by using ViewerApplet. For details, see Using JSPs to print page reports.
  - RunReport
    Demo JSPs for runing report in Advanced mode to various formats. To run the demo, copy the two JSP files to `<intall_root>\public_html\jinfonet`, and then access getRptDescPage2.jsp (runReport2.jsp is called by getRptDescPage2.jsp) using the URL `http://localhost:8888/jinfonet/getRptDescPage2.jsp`.
  - JinfonetGourmetJavaDemo
    Demo JSPs used by the tutorial manual. For details, refer to Track 6: Integrating Reports with JSP in the JReport Tutorial.
- Programs in `<install_root>\help\samples\URLSamples`:
  - ExampleCodeForTags.html
    The sample code for different tags. For details about tags, see Appendix 8: Page Report Studio tag library.
  - TestURL.html
    Some example URLs.