### Lesson 1: Calling a page report from HTML

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

To access this report 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, and then run it. Embedding the report in the application is a more convenient way to present the report. By simply putting a link or a button in the application interface, users can run the report on demand. The report will be displayed in a new web browser window in Page Report Studio 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 Page Report Studio interface or components of it directly into an application interface in minimal time without resource intensive efforts. Component tags can be used for:

- Specifying report outputs.
- Adding toolbars and menu bars to the report, providing easy access to commonly-used functions and commands.
- Adding an interactive table of contents to the report, providing dynamic navigation to any component or section.

This lesson is a simplified version of integration. Extend what this lesson shows to see the full power of JReport 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
- Task 2: Run the report using an HTML file that prepares the Tag lib parameters

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

Any JSP page can call the report. 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>\help\samples\JSPSamples\JinfonetGourmetJavaDemo` 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"> <%@ page import="jet.web.dhtml.WebActLogic"%> <html> <head> <title>Demo</title> </head> <BODY> <iframe style="width:100%; height:100%;" align="middle" scrolling="yes" src="../dhtmljsp/dhtml.jsp?jrs.cmd=jrs.try_vw&jrs.report=/JinfonetGourmetJava/AnnualSalesbyRegion.cls&jrs.catalog=/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. Start JReport Server by clicking Start > All Programs > JReport 13.5 Update 2 > Start Server.
5. Open a web browser window and access http://localhost:8888/jag/runReport.jsp. First log in and then the report is displayed.

#### Task 2: Run the report 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>\help\samples\JSPSamples\JinfonetGourmetJavaDemo` 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 is run.

2. Copy demomain.jsp in `<install_root>\help\samples\JSPSamples\JinfonetGourmetJavaDemo` 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 we run is the AnnualSalesbyRegion.cls.

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

   The Set Page Report Studio Taglib 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 Page Report Studio Taglib Properties page to learn how they affect the way the report is displayed in the Frame (the Tag set ID must be a new one for each running).

#### Lesson 1 summary

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