JReport provides parameters for developer users to run web reports in Web Report 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".
// 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.
}
]
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":"/report.wls","ver":"-1"}&jrd_catalog={"name":"/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\\Products.wls","real":"true"}&jrd_catalog={"name":"C:\\JReport\\Server\\jreports\\SampleReports.cat","real":"true"}
Run Products.wls in the Public Reports folder:
http://localhost:8888/webreport/studio/entry/run.jsp?jrd_report={"name":"/Products.wls"}&jrd_catalog={"name":"/SampleReports.cat"}