JReport Enterprise Server supports four viewers to browse reports from a client: a common browser, JReport Enterprise Viewer for JREntServer, JReport Client API and JReport Viewer Bean. Since JReport Enterprise Viewer and JReport Viewer Bean are all based on Client API, strictly speaking there are two viewers: a common browser and JReport Viewer.
In this chapter, we will learn how to access JReport Enterprise Server through a common browser like IE. Actually, when we learn to configure and administrate JReport Enterprise Server remotely, we have already used a browser through the administration port (8889 by default). Common users will most often access JReport Enterprise Server using IE through the port 8888. Begin with Version 5.1, users can access JReport Enterprise Server with Netscape 7 through port 8888.
Assuming that,
The IP of the machine where the Server runs is 192.168.128.25, and the port where the Server listens is 8888.
Tip: If you don't know the IP of the machine on which the Server runs, and if it is the same machine where you run your Web browser, you can use localhost instead of the IP:
- In the address bar, type http://192.168.128.25:8888.
- Type your user name and password as assigned by your administrator.
For first time users, please type admin and admin as the user name and password.- Click OK to log on to the Server.
The homepage of JReport Enterprise Server will appear, as shown below.
![]()
In the left panel, there is a resource tree of the Server. Click each resource node on the left panel, the corresponding resource under that node will be displayed on the right panel.Notes:
- JReport Enterprise Server can be accessed in two types of web pages - JSP and JRServlet. By default, when you type an URL such as
http://hostname:portnumberin the address bar, the JSP home page will be loaded. This is because JSP is enabled as a default option when JReport Enterprise Server is installed.- To display the JRServlet home page, you need to disable JSP, see User Guide | Configuring JReport Enterprise Server | Remote Configuration | Advanced for information on how to enable or disable JSP.
- However, when JSP is enabled, you still can access the JRServlet home page. To do this, use an URL such as
http://hostname:portnumber/jrserver.
Users can view reports on JReport Enterprise Server. If you just want to have a preview of the report, simply run it to get the view result. If you want to view the report in a different format and save the report result document, please go to AdvancedRun in the Control column to get the view result you want.
To have a preview of a specified report, click the report name in the Name column, or click the Run button in the Control column. You can then view the report in HTML format (the default view format used by JReport Enterprise Server). The default view format can be set in the Preferences page. Please see the Customizing section of this chapter for more details.
To see the running record of the report, please click On-demand on the top banner.
Apart from simply running a specified report to view it in default format, JReport Enterprise Server also supports users to view a specified report in other formats, and save the report result version according to their own requirements. To run the report in the advanced mode:
- Click the AdvancedRun button in the Control column of the report you want to run.
- Archive the report result version by setting the settings on the Archive tab according to your own requirements.
- Go to the Parameters tab to input the values of the parameters (if the report has parameters). You can type the value in the box or select the default value from the drop-down list.
- On the Format tab, choose a format for the report result, and set the other settings.
- Click Submit to view the report in the format that you specified.
Note: For the information about options on each tab, please see the Index for JREntServer Dialogs | The Service Pages | Advanced Run.
JReport Enterprise Server records the running information after you run the report.
To get the record, click On-demands on the top banner, the information is listed in a table. You can remove or add columns in this table on the Preferences page. Please see the Customizing section of this chapter for more details.
To sort the contents to display in ascending or descending order, click the name of the column you want to sort.
For a description of the On-demands table, please see User Guide | Administrating JReport Enterprise Server | Task Management.
JReport Enterprise Server can run reports at a specified time or periodically by scheduling tasks for reports. The scheduled tasks will be recorded by the Server according to their different executing status.
You can schedule tasks for a specified report by clicking the Schedule button in the Control column. The scheduling process is divided into five steps:
- Set the settings for the specified report (the Report tab).
- Specify the type of the task (the Publish tab).
Five task types are provided by JReport Enterprise Server, publishing to version, publishing to disk, publishing to e-mail, publishing to printer and publishing to fax. Choose the type you want and set the settings for the specified type.- Specify the time when the task is to be performed (the Time tab). You can set whether the task is to be performed at a certain time or periodically by changing the settings provided here.
- Notify to someone via e-mail details of : when the task is finished, whether it was successful or unsuccessful (the Notification tab).
- Click Submit to make the Server to perform the task.
Notes:
- For more information about the task type and the options of each tab, please refer to Index for JREntServer Dialogs | The Service Pages | Schedule.
- When publishing a report to disk, you have to specify the name of the file. Please note that the file path should start with a "/", which points to the default resource root %Installroot%\jreports. For example, if you name the file as "Test", you should type "/Test" in the box (it is not necessary for you to type the extension of the file name because the Server will add it automatically). To change the default resource root, go to the Reports page, click Properties under the top banner, and then type the path in the Resource real path box.
If you use a fixed name to perform the task periodically, only the most recently generated report result can be kept. In order to keep the report result generated every time, the dynamic result file name is used. For more information, please refer to Dynamic result file name.- When publishing the report to version and publishing to XML format, if you want to use the URL to get the .xsd file, please follow the steps below:
- Select the Enable JSP check box on the Advanced tab of the Configuration page.
- Put the existing XML schema file under %JREntServer_installroot%\public_html.
- Input http://IP address:8888/name of the existing XML schema file.
- There is another way to publish the report result to version. If you set the property server.version.from.temp = true in the server.properties file under %JREntServer_installroot%\bin, or select the check box Enable Publish to Versioning System for on-demand view on the Advanced tab in the Configuration page of JReport Enterprise Server, you will get the link Publish to Version System on the top of the viewing page. Click the link to publish the result to version.
- When you publish the report to printer and your server runs under jdk 1.3 or an older version, there may be an error regarding field width calculation, and thus the preview result may be partly invisible. To avoid this, please change jdk to 1.4 or a newer version. Also, if there is no printer available connecting with the Server, and you schedule to publish a report result to printer, the Server may crash or throw exception.
JReport Enterprise Server records every scheduled task. Click Schedule on the top banner. There are three tabs on this page: Scheduled, Active, and Completed. The tasks are recorded in different tables according to their executing status. A task is in the Scheduled table as soon as it is submitted by the user, it will go to the Active table when it is running, and when it is finished by the Server, it will then go to the Completed table.
For detailed information about these three tables, please refer to User Guide | Administrating JReport Enterprise Server | Task Management.
When viewing or scheduling a report, JReport Enterprise Server enables you to call your java application before or after the process.
In JReport Enterprise Server, the TaskListener interface is provided in the package jet.server.api for receiving task events before or after running. You can specify one java class to implement this interface for a task event. When the event of this task occurs, corresponding methods in the listener will be invoked. The interface contains two methods: beforeRun and afterRun, enabling you to set your java application call before or after the process of viewing a report or setting up a schedule. Your applications will return true or false. For true, JReport Enterprise Server will go on running; while for false, JReport Enterprise Server will stop there.
Below is an example to illustrate how to add TaskListener when setting up a schedule on a report.
- Develop your java class to implement the interface. In our example, we use TestTaskListener.java.
// This is an example to demonstrate how to implement user's own scripts // before and after task running and how to get the information about a task. import java.util.*; import java.text.DateFormat; import jet.server.api.TaskListener; import jet.server.api.ServerInfo; import jet.server.api.RptServerException; import jet.cs.util.APIConst; // Note: First step: save this file under a proper path, // for example, c:\jrentserver\tasklistener, and edit the batch file // %InstallRoot%\bin\JREntServer.bat by adding the path of the class // file (c:\jrentserver\tasklistener) to the classpath. // Second step: start JReport Enterprise Server and schedule // a report. Check "Add TaskListener to be invoked", and input the class // name, in this example, we input TestTaskListener, and then submit the task. // The result will print in the command window before and after the task // is run. public class TestTaskListener implements TaskListener { private String toVersion = "jet.server.schedule.jrtasks.UpdateRptTask"; private String toFileSystem = "jet.server.schedule.jrtasks.PublishToDiskTask"; private String toEmail = "jet.server.schedule.jrtasks.SendJRMailTask"; private String toPrinter = "jet.server.schedule.jrtasks.PrintRptTask"; // This method will be called automatically BEFORE a task is run, // which means any scripts added into the method will automatically be executed. public boolean beforeRun(ServerInfo serverInfo) { System.out.println("------------- Before Task Running ----------"); try { // "taskType" will store the task-type info got from TaskProperties. // It can be used to determine what kind of task will start to run. String taskType = (String)serverInfo.getTaskProperties().get(APIConst.TAG_TASK_CLASS); if (taskType.equals(toVersion)) { System.out.println("Task Type is: Publish to Versioning System."); } else if (taskType.equals(toFileSystem)) { System.out.println("Task Type is: Publish to File System."); } else if (taskType.equals(toEmail)) { System.out.println("Task Type is: Publish to Email."); } else if (taskType.equals(toPrinter)) { System.out.println("Task Type is: Publish to Printer."); } // "lType" will store the launch-type info got from TaskProperties. // It can be use to determine in which launch type the task will be running. String lType = (String)serverInfo.getTaskProperties().get(APIConst.TAG_LAUNCH_TYPE); if (lType == null) { System.out.println("Launch Type is: Immediately."); } else if (lType.equals(String.valueOf(APIConst.AT_TIME))) { System.out.println("Launch Type is: At time."); } else if (lType.equals(String.valueOf(APIConst.PERIODICALLY))) { System.out.println("Launch Type is: Repeatedly."); } System.out.println ("TaskID is: " + serverInfo.getTaskProperties().get(APIConst.TAG_TASK_ID)); System.out.println ("TaskSubmiter is: " + serverInfo.getTaskProperties().get(APIConst.TAG_UID)); System.out.println ("Report is: " + serverInfo.getTaskProperties().get(APIConst.TAG_REPORT)); System.out.println ("Catalog is: " + serverInfo.getTaskProperties().get(APIConst.TAG_CATALOG)); System.out.println ("Submit time is:" + serverInfo.getTaskProperties().get(APIConst.TAG_SUBMIT_TIME)); // Note: Some information will be created only when the task // who owns them is running. // ExeYear, ExeMonth, ExeDay, ExeHour, ExeMin, and ExeSec // only exist when a periodical task is run. if (lType != null && lType.equals(String.valueOf(APIConst.AT_TIME))) { System.out.println ("ExeYear=" + (String) serverInfo.getTaskProperties().get(APIConst.TAG_EXE_YEAR)); System.out.println ("ExeMonth=" + (String) serverInfo.getTaskProperties().get(APIConst.TAG_EXE_MONTH)); System.out.println ("ExeDay=" + (String) serverInfo.getTaskProperties().get(APIConst.TAG_EXE_DAY)); System.out.println ("ExeHour=" + (String) serverInfo.getTaskProperties().get(APIConst.TAG_EXE_HOUR)); System.out.println ("ExeMin=" + (String) serverInfo.getTaskProperties().get(APIConst.TAG_EXE_MIN)); System.out.println ("ExeSec=" + (String) serverInfo.getTaskProperties().get(APIConst.TAG_EXE_SEC)); } // TaskProperties can provide lots of other useful information, // System.out.println(serverInfo.getTaskProperties()); // By using the script above, you can output all information stored in TaskProperties. System.out.println("For more information, please check <TaskProperties>!\n");; // getTaskProperties and serverInfo.getSchdproperties will throw a RptServerException, // which must be caught.> } catch (RptServerException e) { System.out.println("RptServerException throws out!\n" + "Message in exception object:\n\t" + e.getMessage()); } return true; // if the return value is true, the task will start to run. // if the return value is false, the task will not run. } // This method will be called automatically AFTER a task is accomplished. public void afterRun(ServerInfo serverInfo) { System.out.println("------------- After Task Running ----------"); try { // CompleteTime is not stored in TaskProperties, but it can be obtained // by calling this method. String completeTime = DateFormat.getDateTimeInstance().format(new java.util.Date (System.currentTimeMillis())); System.out.println ("Completed Time=" + String.valueOf(completeTime)); System.out.println ("Engine Message =" + (String) serverInfo.getTaskProperties().get(APIConst.TAG_ENG_MSG)); // isSuccessful only exists after a task is accomplished or terminated with an // error, so it should be obtained only in afterRun() String isSuccessful = (String) serverInfo.getScheduleProperties().get(APIConst.TAG_IS_SUCCESSFUL); if (isSuccessful == "false") { // Task is terminated with errors, // System.out.println ("Error Message =" +(String)serverInfo.getTaskProperties().get(APIConst.TAG_ERROR)); // Another alternative is using the script above to output error details. System.out.println("Task terminated with some errors. \nFor more information, please check <TAG_ERROR of TaskProperties>!"); } else { System.out.println("Task accomplished successfully!\n"); } } catch (RptServerException e) { System.out.println("RptServerException throws out!\n" + "Message in exception object:\n\t" + e.getMessage()); } } }- Compile TestTaskListener.java to generate the class file.
- Edit the batch file %InstallRoot%\bin\JREntServer.bat, which is used to start the JREntServer. Suppose TestTaskListener is saved in
c:\jrentserver\tasklistener, add the path of the class file (c:\jrentserver\tasklistener) to the classpath in JREntServer.bat.- Start JReport Enterprise Server and set up a schedule on a report. Check Add TaskListerner to be invoked, and input the class name with its package, in this example, input TestTaskListener. Then submit the task.
- In this example, the class returns "
True".
Print out the task properties and schedule properties before and after running the task. So you will get task and schedule information in the command window before and after the task is run.You can also define properties of your own and transmit them through ServerInfo. To do so, you use
APIConst. TAG_USERDEFINED_PROPERTY_PREFIXas the prefix for the properties.For example, if you want to transmit the properties
host_name, host_ipandhosp_protocol, you need to insert the properties, before calling the method runTask, into the Properties named prop, as follows:
prop.put(APIConst. TAG_USERDEFINED_PROPERTY_PREFIX+"host_name", "host"); prop.put(APIConst. TAG_USERDEFINED_PROPERTY_PREFIX+"host_ip", "192.10.10.6"); prop.put(APIConst. TAG_USERDEFINED_PROPERTY_PREFIX+"host_protocol"+ "TCP/IP");You can get the value of the properties listed above through the ServerInfo object, serverInfo, in the method beforeRun or afterRun of the TaskListener class. See the example below:
host_name=serverInfo.getTaskProperties().get(APIConst.TAG_USERDEFINED_PROPERTY_PREFIX+"host_name"); host_ip=serverInfo.getTaskProperties().get(APIConst.TAG_USERDEFINED_PROPERTY_PREFIX+"host_ip"); host_protocol=serverInfo.getTaskProperties().get(APIConst.TAG_USERDEFINED_PROPERTY_PREFIX+"host_protocol");Note: All properties without the prefix,
APIConst. TAG_USERDEFINED_PROPERTY_PREFIX, will be denied and discarded by JReport Enterprise Server.
To speed up the report delivery, JReport Enterprise Server supports to deliver a single page of content at a time. JReport Engine outputs the content of result in Html file to the browser as soon as a single page has finished processing, while the rest of the report will continue to be processed. Users can navigate the report result to the previous or next page.
Please note that data such as Total Page Number displayed in one page may be temporary, which we call "dirty data". When data in a chart spans across one page, it is also displayed with dirty data. The Dirty data will be refreshed when JReport Engine finishes processing.
On the home page, clicking Preferences on the top banner, the Preferences page will then appear. Users can change their password and customize their web pages easily. All changes that each user's make will take effect the next time they log on to JReport Enterprise Server.
To change password,
- Go to the Preferences page and then click the Change Password tab.
- Enter the required information for each option.
- Click Submit to apply the changes and the password is changed.
Notes:
- Ordinary end users can only change their own passwords.
- Users belonging to the administrator group can change passwords for all users.
- Please make sure that the Executor Password is identical with the current user's password.
To customize the web pages,
- Go to the Preferences page and then click the Customize tab.
- Set the settings according to your requirements.
- Click Submit to apply the changes to customize the web pages.
For more information about customizing, please refer to JREntServer Dialogs | The Service Pages | Preferences.
Click Logout on the top banner to log off JReport Enterprise Server. A logged out page will then be displayed. If you want to log back again, click the click here link.
In our Server, the program exits normally when clicking the Shut Down button in admin page (in standalone environment) or when shutting down the application server the right way (in integration environment). Also, we provide a feature for handling an abnormal system exit to enable the program to close itself gracefully when the virtual machine is terminated in response to a user interrupt, such as typing ^C, or a system-wide event, such as user logoff or system shutdown. However, the user platform has to use JDK 1.3 or above to apply the feature. We suggest that users shut down the Server normally.