Using JSPs in Oracle Reports

Advanced Concepts 2-7 See also Section 1.2.2, About Web Reports

2.2.1 About JavaServer Pages JSPs and servlets

JavaServer Pages JSPs technology is an extension to the Java servlet technology from Sun Microsystems that provides a simple programming vehicle for displaying dynamic content on a Web page. A JSP is an HTML page with embedded Java source code that is executed in the Web server or application server. The HTML provides the page layout that is returned to the Web browser, and Java provides the business logic. JSPs keep static page presentation and dynamic content generation separate. Because JSPs cleanly separate dynamic application logic from static HTML content, Web page designers who have limited or no Java programming expertise can modify the appearance of the JSP page without affecting the generation of its content, simply using HTML or XML tags to design and format the dynamically-generated Web page. JSP-specific tags or Java-based scriptlets can be utilized to call other components that generate the dynamic content on the page. JSPs have the .jsp extension. This extension notifies the Web server that the page should be processed by a JSP container. The JSP container interprets the JSP tags and scriptlets, compiles the JSP into a Java servlet and executes it, which generates the content required, and sends the results back to the browser as an HTML or XML page. A JSP can be accessed and run from a browser-based client, typically over the Internet or a corporate intranet. Unlike traditional client-server applications, JSP applications: ■ run on a wider variety of client machines and browsers. ■ run on thinner clients, thereby consuming fewer client-machine resources. ■ scale to a larger number of simultaneous users. ■ require less effort to install and maintain. When a JSP is called for the first time, it is compiled into a Java servlet class and stored in the Web servers memory. Because it is stored in memory, subsequent calls to that page are very fast, thereby avoiding the performance limitations seen with traditional Common Gateway Interface CGI programs, which spawn a new process for each HTTP request. For additional background information about JSP technology, see the Sun Microsystems Java and Java EE Web site at http:java.sun.com .

2.2.1.1 Using JSPs in Oracle Reports

Oracle Reports supports JavaServer Pages JSPs as the underlying technology to enable you to enhance Web pages with information retrieved using Oracle Reports Builder. In Oracle Reports, you use JSPs to embed data retrieved using the data model into an existing Web page to create a JSP-based Web report. You can create new JSP reports, or save existing reports as JSP reports. New reports are by default saved as JSP reports. The benefit of saving reports as JSPs is that JSPs are text files that are easy to edit as opposed to, for example, the binary .rdf format. When a report is saved as a JSP file, the data model is embedded using XML tags. The entire report can now be defined using XML tags and saved as an XML file. Using the Oracle Reports custom JSP tags, you can easily add report blocks and graphs to existing JSP files. These tags can be used as templates to enable you to build and insert your own data-driven Java component into a JSP-based Web report. Not only 2-8 Oracle Reports Users Guide to Building Reports can you edit the HTML or XML code that encapsulates the report block, but you can also edit the report block in the JSP itself, by modifying, adding or deleting their bodies and attributes. The Report Editors Web Source view displays the source code for your Web report, including HTML, XML, and JSP tags. By default, a new JSP created in Oracle Reports Builder contains the following: page contentType=texthtml;charset=ISO-8859-1 If you are creating your JSP outside Oracle Reports Builder, you should ensure that it contains similar encoding information. In prior releases, Oracle Reports introduced Web links that you can add to paper-based reports, which become active when you display your paper report in a Web browser or PDF viewer. For JSP reports, hyperlinks have to be created manually, and if the hyperlinks need to substitute data values, the data values must be provided through the rw:field JSP tag. For example: a href=http:hostname:portpathrwservlet?report=department.jspp_ deptno=rw:field id=F_Deptno src=Deptno rw:field id=F_Deptno src=Deptno10rw:field a

2.2.1.2 Opening or running an encoded JSP-based Web report