Lesson 5: Deploying JReport with Client/Server
There are three methods for you to view your reports via Internet or Intranet.
All these methods are discussed in this tutorial.
JReport's Client/Server system allows you to view reports via Internet or Intranet. In this configuration, JReport Viewer and JReport Server typically run as separate programs on different computers connected in a network. (Note that however, you can also run them on the same computer during testing of your reports.) The Viewer sends out a request to the Server. The Server will run the report and then send the report results that are requested by the Viewer.
Setting up the Server
Step 2:
Double click on the JRServer.bat in the \JRServer\bin subdirectory (assuming that is the place where you installed JReport Server) to start up the server. The following window should appear:
Using the Viewer


The left menu displays which catalog files are available to you on the server. The right menu shows which reports are listed under the catalog file selected. To view a report from the JReport Viewer, select a report and click on the Open button. You can also view a report by selecting a report and clicking File/Open and then Remote.
Sometimes it is desirable to save a report for future use without needing to run it again. Any time when you view a report using the JReport Viewer you can save it as a local file by clicking File/Save As... The report will be saved as an indexed report result file. Once a report is saved, you can use File/Open/Local to open and view this indexed result file instead of running it on the JReport Server again.
For this example, we selected the invoice report from the Tutorial catalog on the Server. Thus we are requesting the Server to run the invoice report Remotely.
Step 4:
Once the result is available, the following window will appear.
This section is intended only for Java developers.
In order to make the JReport Viewer easier to be called from user's Java application, the Viewer program is also provided as a Java Bean. The JReport Viewer Bean can send a request from a client workstation to the Server and instruct the Server to run a report and return results to the Viewer.
Setting up the JReport Viewer Bean
The file JRViewer.zip should be used when compiling your program which will call the JReport View Bean. The JRViewer.zip file should also be used when you run your application which calls JReport View Bean.
There are three methods to invoke the JReport View Bean, depending on how much control your application requires:
If you know which method you will use at run time, instead of using the JRViewer.zip file, you can use one of the other two (smaller) jar files (OneStepJRViewer.jar and TwoStepsJRViewer.jar). The following sections show how to use each of the two methods.
Please note that regardless which method you use, getStatus () should be called each time after calling the Viewer Java beans. If the return string is "OK", the request is accepted, otherwise an error message is returned.
The First Method: One Step JReport Viewer
After the Java bean JRDirectViewer is loaded, it will ask the JReport Server to run the report and pop up a dialog on the screen to ask the user to input the report parameter, if needed. This method of invoking the JReport Viewer Bean has the advantage that it does not require the user's Java application to provide the report parameters. The disadvantage is that it will display a dialog on the screen to ask user to input the report parameters.
After the Viewer have successfully received the report results, you may want to have them printed. There are also two methods available for printing reports. They are:
Printing is initiated by calling the method printReport (). While the report is being printed, you can call the getPrintStatus () method to get the current status of the print job. The return values of the getPrintStatus () are:
Please note that these two printing methods are also available to the second method of calling JReport Viewer Bean described below.
The Second Method: Two Steps JReport Viewer
The second method of invoking the JReport Viewer Bean is that the user's Java application first calls a Java bean named JRPrepareViewer with the following properties:
The JRPrepareViewer Java Bean will return a vector which contains the information about the report. The user's Java application should prepare the parameters based on the information provided by the vector. The data type of the parameters may be obtained by calling the method getReportParams () which returns a vector. The size of the vector depends on the number of the parameters needed by the report. Each element in the vector contains the type of one parameter. You can use getType () method to get it. The following are the types of parameters available:
After the parameters are prepared, you will then call the second Java bean named JRRunViewer with the following properties:
In the second method of invoking the JReport Viewer Bean, our bean will not display any dialog on the screen. However, the user's Java application has to provide all the necessary information and retain full control to the screen. We note that there is a lot of redundant parameters in the two calls. This will be improved in a future version.
The Third Method: Second Step JReport Viewer
The example program Sample1 and Sample2 illustrate how to call JReport Viewer Beans. Please refer to it for further details.
You can select menuitem " setWherePortion2" from menu for run report and get the result that the Customers_Customer ID less than 20.