J2EE Report Generation

This article continues the explanation of how to take advantage of InetSoft's JSP tag libary for integrating reports into your Web application.

Read how InetSoft saves money and resources with deployment flexibility.

The Create Tag

The next tag needs to be the 'create' tag. This tag specifies the report that will be embedded in the JSP. It also handles the generation of the report and serves all of the resources required by the report.

There cannot be any HTML content or JSP tags that generate content before this tag. The create tag handles serving images and static files such as cascading style sheets and JavaScript files. If there is any content before this tag, it will be included in the resource file and will corrupt it. If you require that there be content before the create tag, you must specify the resourceUri attribute. This attribute should be set to the URL of a Servlet Repository deployed in the same web application. The Servlet Repository and the JSP tag library share the same resources and report server, so there is very little additional overhead.

In WebLogic, there also cannot be any characters (i.e., new lines) outside of JSP tags before the create tag. WebLogic will print these characters to the output stream, corrupting the image file. Setting the resourceUri attribute will solve this problem.

The create tag has two required attributes, reportId and name. The reportId attribute is a unique string that identifies all subsequent tags as referring to this report. This allows you to include more than one report in a single JSP page. The reportId need only be unique within the JSP, not within the entire web application. The name attribute is the name of the replet as it is registered in the Replet Repository. The name should include all folders in its path, separated by a forward slash (/).

The create tag also has one optional parameter, processPage. This attribute determines the behavior of the JSP if the report is not yet available. If processPage is set to false, the remainder of the JSP is not processed and the text “Loading Report...” is displayed. If processPage is set to true, the JSP is processed and the content included in the body of the subsequent report tags is displayed in place of the report element.

<sree:create reportId="myReport" name="My Folder/My Report" processPage="true"/>

The Parameter Tag

The create tag can also contain parameter tags. These tags pass report parameters to the report. The parameter tag has three required attributes: name, value, and type. The name attribute specifies the name of the parameter, the value attribute specifies the value of the parameter, and the type attribute specifies the data type of the parameter value. The allowed parameter types are listed in Appendix C: Tag Library Reference. If the type is “date”, you also need to include the format attribute. The format attribute specifies the format in which the value is being passed and should use the format specified in java.text.SimpleDateFormat.

 <sree:create reportId="report1" name="A Report" processPage="false">
 <sree:parameter name="State" value="NY" type="string"/> 
 <sree:parameter name="Order Date" value="2003-05-01"    type="date" format="yyyy-MM-dd"/>

If a report parameter has the same name as a JSP request parameter, it will be passed to the report without having to include a parameter tag. Using a parameter tag in this case will override the value of the JSP parameter.