JReport provides parameters for developer users to run web reports in JReport Studio via URL. All the parameters are encapsulated as JSON (JavaScript Object Notation) objects. Therefore, it will help if you obtain some knowledge on JSON to understand the syntax more clearly. When composing the URL, you need to use URL encoding to avoid errors.
The following lists the parameters for running web reports via a URL:
{
// 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".
},
{
// 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.
}
]
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_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\\Products.wls","real":"true"}&jrd_catalog={"name":"C:\\JReport\\Server\\jreports\\SampleReports\\SampleReports.cat","real":"true"}
Run Products.wls in the Public Reports > SampleReports folder:
http://localhost:8888/webreport/studio/entry/run.jsp?jrd_report={"name":"/SampleReports/Products.wls"}&jrd_catalog={"name":"/SampleReports/SampleReports.cat"}