Lesson 1: Calling a DHTML report set from HTML

You have been asked to embed AnnualSalesbyRegion.cls with the Jinfonet Gourmet Java Sales Orders application. This report set shows annual sales information. The report set will be called from a JSP page in the application.

To access this report set without being embedded, the user has to leave the application interface, open a new web browser window, point it to the JReport Console page, locate the report set, and then run it. Embedding the report set in the application is a more convenient way to present the report set. By simply putting a link or a button in the application interface, users can run the report set on demand. The report set will be displayed in a new web browser window in DHTML format and not affect the state of the application.

To access JReport functionality from a JSP page, you use the JReport JSP Tag Library. The JReport JSP Tag Library provides a collection of reusable embedded and component tags that can be incorporated into web applications. Using these tags, developers can easily embed JReport's entire DHTML interface or components of it directly into an application interface in minimal time without resource intensive efforts. Component tags can be used for:

For complete information about the JReport JSP Tag Library, see Appendix 7: DHTML tag library in the JReport Enterprise Server User's Guide.

This lesson is a simplified version of integration. Extend what this lesson shows to see the full power of JReport Enterprise Server running in either of its two modes: as an integrated part of your application or as a standalone report server independent of the application.

Task 1: Access the JSP file that runs the report set

Any JSP page can call the report set. For this lesson, a simple JSP page is used. To view the .jsp file, follow these steps:

  1. Create a new directory named jag in <install_root>\public_html.
  2. Browse to and copy runReport.jsp in <install_root>\Demo\source to <install_root>\public_html\jag.
  3. In your favorite HTML editor, open runReport.jsp and review the JSP code. It contains:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">			  
    <html>
    <head>
    <title>JReport DHTML</title>
    </head>
    
    <BODY>
    <iframe style="width:800px; height:600px; top:50px;; left:10px;" align="middle"
    frameborder="1" marginheight="10"; marginheight="10" scrolling="yes"
    src="../dhtmljsp/dhtml.jsp?jrs.cmd=jrs.try_vw&jrs.report=/USERFOLDERPATH/
    admin/JinfonetGourmetJava/AnnualSalesbyRegion.cls&jrs.catalog=
    /USERFOLDERPATH/admin/JinfonetGourmetJava/JinfonetGourmetJava.cat&"/>
    </BODY>
    </HTML>

    Note: The sc string value is broken for display purposes only in this document. In the actual .jsp file the value is continuous.

  4. Open a web browser window and access http://localhost:8888/jag/runReport.jsp

    The report set is then displayed.

Task 2: Run the report set using an HTML file that prepares the Tag lib parameters

This task provides an example of how the parameters to the main page tag interact with each other to control the report output. In this example, you enter values for each parameter into an HTML page before running the report. A more likely scenario for a real application is to have the to application code specify the parameters rather than prompt the user for them.

  1. Copy setmain.html in <install_root>\Demo\source to <install_root>\public_html\jag.

    Review the code if desired. This code creates a frame and prompts for the parameter values that the main page tag requires. When you click the submit button the parameters are passed to the JSP page and the report set is run.

  2. Copy demomain.jsp in <install_root>\Demo\source to <install_root>\public_html\jag.

    Review the code if desired. This is very similar to the code from Task 1 except that the values are passed in from the HTML page and the report set we run is the AnnualSalesbyRegion.cls.

  3. Open a web browser and access http://localhost:8888/jag/setmain.html

    The Set DHTML Main page tag properties page appears:

  4. Click submit to run the report with the defaults.

    If desired, repeat the steps in this task and experiment with different values on the Set DHTML Main page tag properties page to learn how they affect the way the report set is displayed in the Frame (the Tag set ID must be a new one for each running).

Lesson 1 summary

In this task you have learned how to use HTML and JSP to run a report set using the JReport JSP Tag Library.