You can use the following JSP's to run reports via URL: tryView.jsp, runReport.jsp, and run.jsp. However Page Report Studio and Web Report Studio have permission control, so in order to run reports in Web/Page Report Studio you are required to have the Execute and/or Edit permissions on the reports.
The image illustrates the relationship between the JSPs:
This is the normal method of accessing reports using URLs. tryView.jsp can be used to run page reports and web reports to any allowed formats.
If the report has parameters and no parameter specified in the URL or the parameters provided in the URL fail to include all necessary parameters, the server then displays the parameter dialog for entering parameter values.
Below are some examples:
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=%2fSampleReports%2fEmployee Information List.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=8
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=%2fSampleReports%2fEmployee Information List.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=2
http://localhost:8888/jinfonet/tryView.jsp?&jrs.report=%2fSampleReports%2fSales Detail Report.wls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=8
http://localhost:8888/jinfonet/tryView.jsp?&jrs.report=%2fSampleReports%2fSales Detail Report.wls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=1
This JSP functions the same as tryView.jsp when the report has no parameters. When it has parameters, the report runs with the default parameters if no parameter values are specified, or else it runs with the parameters specified in the URL.
runReport.jsp can be used to run page reports and web reports to any allowed formats.
Below are some examples:
http://localhost:8888/jinfonet/runReport.jsp?jrs.report=%2fSampleReports%2fABC.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=1
&&jrs.param$P_StartDate=2016-01-01&jrs.param$p_EndDate=2017-12-31
http://localhost:8888/jinfonet/runReport.jsp?jrs.report=%2fSampleReports%2fSales Detail Report.wls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=8
run.jsp can be used to run page reports in Page Report Studio and web reports in Web Report Studio. When it has parameters, the report runs with the default parameters if no parameter values are specified, or else it runs with the parameters specified in the URL.
http://localhost:8888/webos/app/pagestudio/run.jsp?jrs.report=%2fSampleReports%2fEmployee Information List.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat
run.jsp can also be used in the following scenarios:
In addition to the above JSPs, you can call the server servlet jrserver to run reports to any allowed format. However when you use servlet to run a report, JReport redirects the request to an appropriate JSP so it is recommended to use JSP to run the report directly. The following are two examples:
http://localhost:8888/jrserver/SampleReports/SampleReports.cat/Employee Information List.cls?jrs.cmd=jrs.web_vw&jrs.result_type=8
http://localhost:8888/jrserver/SampleReports/SampleReports.cat/Sales Detail Report.wls?jrs.cmd=jrs.web_vw&jrs.result_type=1
For detailed information about the properties that are included in the URLs, see Appendix 1: URL Properties.
Below are some more specific topics about running reports via URL:
If you want to run a specific page report tab, use jrs.report_sheet$RPT_TAB_NAME=true to specify a report tab in the current page report, where RPT_TAB_NAME is the report name of the specific report tab, not the display name. For example, jrs.report_sheet$Report2=true.
To get the report name and display name of a page report tab you can open the page report in JReport Designer and look at the Instance Name property in the Report Inspector or you can make use of the API methods getName() and getDisplayName() in the interface jet.server.api.ReportSheetInfo. For the detailed usages, see the JReport Javadoc located in <install_root>\help\api
.
The URL for running the report tab Financial report in Page Report Studio within the report Detail Report Corporate Overview.cls is as follows:
http://localhost:8888/jinfonet/tryView.jsp?jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.report=%2fSampleReports%2fDetail Report Corporate Overview.cls&jrs.result_type=8&jrs.report_sheet$report2=true
When running a page report in Page Report Studio, you can ask JReport to automatically refresh the report data at certain interval. To achieve this, you need to run the report with run.jsp and add the following two properties in the URL:
The following is a URL example:
http://localhost:8888/webos/app/pagestudio/run.jsp?jrs.report=%2fSampleReports%2fEmployee Information List.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.auto_refresh_data=true&jrs.auto_refresh_data_time=10
JReport provides properties for developer users to run web reports in Web Report Studio via JSON (JavaScript Object Notation).
The following lists the properties that are encapsulated as JSON objects. It will help if you obtain some knowledge on JSON to understand the syntax more clearly.
{
// JDBC data source.
"ds":"Data Source 1", // Data source name.
"uid":"xxx", // DB user name.
"pwd":"xxx", // DB user password.
"type":0, // Indicates it is JDBC data source.
"url":"xxx", // JDBC URL. For example, "url":"jdbc:oracle:thin:@127.0.0.1:1521:ora8i".
"driver":"xxx" // JDBC driver. For example, "driver":"oracle.jdbc.driver.OracleDriver".
// When connecting to a different database with different database metadata or data metadata, you need to also specify the following commands to set the target database metadata information if there are differences:
"refresh_support_info":True, // Optional. Value: True/False. If it is true, JReport will get support information including reverse words, quote characters, and so on from the driver each time fetching data from the database. It is recommended that you set this property to true when connecting to a different database.
"quote_character":"xxx", // Optional. The quote characters.
"extra_characters":"xxx", // Optional. The extra characters.
"date_format":"xxx", // Optional. The date format.
"datetime_format":"xxx", // Optional. The datetime format.
"time_format":"xxx", // Optional. The time format.
"transaction_readonly":"xxx", // Optional. The transaction "read only" property. Possible value: default, Read only, or Read&Write. Ignore other values.
"transaction_mode":"xxx", // Optional. The transaction mode. Possible value: default, None, Read Uncommitted, Read Committed, Repeatable Read, or Serializable. Ignore other values.
"char_to_be_replaced":"xxx", // Optional. The characters that are to be replaced.
"char_replaced_by":"xxx" // Optional. The characters used to replace the characters specified by char_to_be_replaced.
},
{
// JNDI data source. Currently JReport only supports local JNDI with anonymous lookup which means that the JNDI data source and the report server are in one JVM and the JNDI needs no authentication.
"ds":"Data Source 2", // Data source name.
"uid":"xxx", // DB user name.
"pwd":"xxx", // DB user password.
"type":1, // Indicates it is JNDI data source.
"url":"xxx", // JNDI name. For example, "url":"jndi/testDB".
},
{
// Java DataSource object/Connection object/ResultSet object.
// Users should define request or session attribute, then the attribute key is the one defined in the request.
// For example, write user.jsp as follows:
// String key = "Rst";
// java.sql.ResultSet rst = null;
// rst = // Gets result set object from user own business logic.
// request.setAttribute("Rst", rst);
// Then the key would be that "key":"Rst".
// The above example is based on ResultSet object. It also applies to the other two types.
"ds":"Data Source 3", // Data source name.
"type":2/3/4, // Indicates the data source type.
"key":"xxx" // Request attribute object name, included in request or session.
}
]
When composing the URL, you need to use URL encoding to avoid errors.
Here is an example of the complete URL without URL encoding to make it easier to read:
http://localhost:8888/webreport/studio/entry/run.jsp?jrd_report={"name":"/SampleReports/report.wls","ver":-1}&jrd_catalog={"name":"/SampleReports/SampleReports.cat","ver":-1}&jrd_param$={"P_Coutry":"USA"}&jrd_security_file_name={"name":"SampleReports.security.xml"}&jrd_datasources=[{"ds":"Data Source 1","uid":"xxx","pwd":"xxx","type":0,"url":"xxx","driver":"xxx"},{"ds":"Data Source 2","type":2,"key":"xxx"}]
If you use absolute resource path, you need to add the property "real":true for the path. For example,
jrd_report={"name":"C:\\JReport\\Server\\jreports\\SampleReports\\Sales Detail Report.wls","real":true}&jrd_catalog={"name":"C:\\JReport\\Server\\jreports\\SampleReports\\SampleReports.cat","real":true}
Run Sales Detail Report.wls in the Public Reports > SampleReports folder:
http://localhost:8888/webreport/studio/entry/run.jsp?jrd_report={"name":"/SampleReports/Sales Detail Report.wls"}&jrd_catalog={"name":"/SampleReports/SampleReports.cat"}
Web Report Studio has two modes: View Mode and Edit Mode. When opening web reports in Web Report Studio by URL, you can use the property jrd_studio_mode to specify the mode. If this property is not provided in the URL, the default mode set in the server profile will be applied.
Below are the values of the property:
However for web reports saved in public folders in the server resource tree, Web Report Studio adopts a permission control to restrict user access, so whether the specified mode can be opened depends on if you have the Execute and/or Edit permissions on the web reports: Execute for View Mode and Edit for Edit Mode. If you do not have the required permission on the public web report you are going to run:
Example:
http://localhost:8888/webreport/studio/entry/run.jsp?jrd_report={"name":"/SampleReports/Sales Detail Report.wls"}&jrd_catalog={"name":"/SampleReports/SampleReports.cat"}&jrd_studio_mode=view
Page Report Studio has two views: Basic View and Interactive View. When opening page reports or page report results in Page Report Studio by URL, you can use the property jrd_studio_mode to specify the view. If this property is not provided in the URL, the default view set in the server profile will be applied.
Below are the values of the property:
However for page reports and page report results saved in public folders in the server resource tree, Page Report Studio adopts a permission control to restrict user access, so whether the specified view can be opened depends on if you have the Execute and/or Edit permissions on the page reports or page report results: Execute for Basic View and Edit for Interactive View. If you do not have the required permission on the public page report or page report result you are going to run:
Examples:
http://localhost:8888/webos/app/pagestudio/run.jsp?jrs.report=%2fSampleReports%2fEmployee Information List.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrd_studio_mode=interactive
http://localhost:8888/webos/app/pagestudio/run.jsp?jrs.resource_path=%2fUSERFOLDERPATH%2fadmin%2ftest&jrs.file=1980996366.rsd&jrd_studio_mode=basic_only
Take the following examples to specify a time duration for a report run task, and ask JReport Server to notify someone of the task status via e-mail if the task has not yet finished running when the task duration is up:
Use tryView.jsp to run a report without a parameter:
http://localhost:8888/jinfonet/tryView.jsp?&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.report=%2fSampleReports%2fEmployee Information List.cls&jrs.timeout_send_email=true&jrs.report_timeout=5&jrs.mailto=person@company.com&jrs.mailsubject=TaskForTimeoutSendEmail&jrs.result_type=1&jrs.mailcomments=IFTHEREPORTISFINISHEDTHERESULTWILLBESENT&jrs.mailfrom=person@company.com
Use runReport.jsp to run a report with parameters:
http://localhost:8888/jinfonet/runReport.jsp?jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.report=%2fSampleReports%2fABC.cls&jrs.param$P_StartDate=2016-1-1&jrs.param$p_EndDate=2017-12-31&jrs.timeout_send_email=true&jrs.report_timeout=1&jrs.mailto=person@company.com&jrs.mailsubject=AboutTaskForTimeout&jrs.result_type=1
You can also set a message in the e-mail by setting the property jrs.timeout_sendmail_message.
For example, you want to display message as follows:
Running <report name> takes more than <Timeout> seconds.
The subject is <mail subject> and has been sent to <mailto> from <mailfrom>
It is a file whose type is <type>.
Then you can set the property in URL as follows:
jrs.timeout_sendmail_message=Running {6} takes more than {0} seconds.<p>The subject is {2} and has been sent to {1} from {5}.<p>It is a file whose type is {3}.
Where
{0} - The report timeout
{1} - mail to
{2} - mail subject
{3} - result type
{4} - mail comment
{5} - mail from
{6} - Catalog name/report
<p> - an Enter key
Example
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=%2fSampleReports%2fEmployee Information List.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.timeout_send_email=true&jrs.report_timeout=1&jrs.mailto=person@company.com&jrs.mailsubject=AboutTaskForTimeoutSendEmail&jrs.result_type=1&jrs.mailcomments=Employee Information List&jrs.mailfrom=person@company.com&jrs.timeout_sendmail_message=.This {6} is a large report whose runtime is over {0} seconds.<p>The report is sent to {1} from {5}.<p>The subject of the mail is {2}.<p>Its type is {3}.
When accessing reports via URL, you can switch the connection in the same database or between different databases at runtime by setting the properties: jrs.jdbc_url, jrs.jdbc_driver, jrs.db_user and jrs.db_pswd. As a result, if the databases you want to switch between have the same structure, you will then be free from having to build another similar catalog. You can use the switch database commands to set the JDBC connection or to change the user name/password in order to connect to another database.
See also:
Switching the connection and user/password in the same database
The URL for switching the connection:
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=%2fSampleReports%2fReport1.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=1&jrs.jdbc_url=jdbc:oracle:thin:@host:1521:demo
The URL for switching the connection:
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=%2fSampleReports%2fReport1.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=1&jrs.jdbc_url=jdbc:inetdae:host:1433?database=JTTest&sql7=true
The URL for switching the user ID and password:
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=/SampleReports/Report2.wls&jrs.catalog=/SampleReports/SampleReports.cat&jrs.result_type=8&jrs.db_user=Scott&jrs.db_pswd=tiger
The URL for switching the connection:
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=%2fSampleReports%2fReport2.wls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=1&jrs.jdbc_url=jdbc:sybase:Tds:host:5000/product
Switching the connection between different databases with the same database metadata
The URL for switching the connection:
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=%2fSampleReports%2fReport1.cls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=1&jrs.jdbc_driver=sun.jdbc.odbc.JdbcOdbcDriver&jrs.jdbc_url=jdbc:odbc:products
The URL for switching the connection:
http://localhost:8888/jinfonet/tryView.jsp?jrs.report=%2fSampleReports%2fReport2.wls&jrs.catalog=%2fSampleReports%2fSampleReports.cat&jrs.result_type=1&jrs.jdbc_driver=com.inet.tds.TdsDriver&jrs.jdbc_url=jdbc:inetdae:JT_P05:1433?database=products&sql7=true
Switching the connection between different databases with different database metadata
When connecting to a different database with different database metadata or data metadata, you need to also specify the following properties to set the target database metadata information if there are differences:
The URL for switching the database to Oracle when running the page report report1.cls:
http://localhost:8080/remote/sub/jinfonet/tryView.jsp?jrs.catalog=/Test/Test.cat&jrs.report=/Test/report1.cls&jrs.cmd=jrs.try_vw&jrs.result_type=8&jrs.jdbc_driver=oracle.jdbc.driver.OracleDriver&jrs.jdbc_url=jdbc:oracle:thin:@192.168.0.1:1521:oracle9&jrs.db_user=test&jrs.db_pswd=1234&jrs.db_quote_character="&jrs.db_date_format=M/d/yyyy&jrs.db_datetime_format=d/M/yyyy h:mm:ss a&jrs.db_time_format=HH:mm:ss.SSS&jrs.db_transaction_readonly=Read Only&jrs.db_transaction_mode=Repeatable Read&jrs.db_char_to_be_replaced=}&jrs.db_char_replaced_by=}oracle91234