0197-0199

Previous Table of Contents Next

Page 197

Other advantages are inherent in multi-process architecture of the Web Application Server itself, which provides improved scalability, reliability, and performance through its distributed process management and monitoring capabilities.

The LiveHTML Cartridge

The LiveHTML cartridge is Oracle's implementation of the NCSA-standard Server Side Includes (SSI). LiveHTML allows an HTML page to include content from other HTML sources, both static and dynamic. A LiveHTML file differs from a standard HTML file in that it is parsed by Web Application Server. To make its commands available to the parser, LiveHTML includes formatted comments:

 <!--#include   \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?'))window.location='http://news.dcn-asu.ru/BOOKS/Oracle.Unleashed.Second.Edition/ch09/url="http:/www.acme.com/templ/stdhead.html>'" tppabs="http://news.dcn-asu.ru/BOOKS/Oracle.Unleashed.Second.Edition/ch09/url="http:/www.acme.com/templ/stdhead.html>">URL="http://www.acme.com/templ/stdhead.html> 

The formatting wraps the command that is processed by the LiveHTML cartridge. In the preceding code segment, the command is request for an HTML page. LiveHTML is easy to use because there are so few commands. Table 9.2 lists these commands and their uses.

Table 9.2. The full set of LiveHTML commands.

Command Purpose
config Sets parameters to indicate how included files or scripts should be parsed.
include Specifies a file to be included in the content.
request Includes the results of an HTTP request (such as a PL/SQL cartridge
request).
fsize Displays the size of a specified file.
flastmod Displays the last modification date of a specified file.
exec Executes a specified script (CGI or operating system).
echo Displays the value of an environment variable.

The best use of the LiveHTML cartridge is piecing together content from existing (and relatively static) sources. For example, you can use LiveHTML to place a standard header and footer on press releases:

 <!--#include   \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?'))window.location='http://news.dcn-asu.ru/BOOKS/Oracle.Unleashed.Second.Edition/ch09/url="http:/www.acme.com/templ/stdhead.html>'" tppabs="http://news.dcn-asu.ru/BOOKS/Oracle.Unleashed.Second.Edition/ch09/url="http:/www.acme.com/templ/stdhead.html>">URL="http://www.acme.com/templ/stdhead.html> <!--#include   \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?'))window.location='http://news.dcn-asu.ru/BOOKS/Oracle.Unleashed.Second.Edition/ch09/url="http:/www.acme.com/pressrel/051597/newprod/page1.html>'" tppabs="http://news.dcn-asu.ru/BOOKS/Oracle.Unleashed.Second.Edition/ch09/url="http:/www.acme.com/pressrel/051597/newprod/page1.html>">URL="http://www.acme.com/pressrel/051597/newprod/page1.html> <!--#include   \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?'))window.location='http://news.dcn-asu.ru/BOOKS/Oracle.Unleashed.Second.Edition/ch09/url="http:/www.acme.com/templ/stdfoot.html>'" tppabs="http://news.dcn-asu.ru/BOOKS/Oracle.Unleashed.Second.Edition/ch09/url="http:/www.acme.com/templ/stdfoot.html>">URL="http://www.acme.com/templ/stdfoot.html> 

The stdhead.html and stdfoot.html can contain images, hyperlinks , and other content that is standardized and relatively static. The use of Server Side Includes (SSI) to format static press releases allows a change in one of these HTML files to be reflected in all press releases.

Page 198

TIP
Although LiveHTML can use the request command to access the database through the PL/SQL cartridge (via the intercartridge exchange), you should limit this use of LiveHTML. You can use the PL/SQL cartridge to provide many of the same capabilities as the LiveHTML cartridge, so it is preferable to use the PL/SQL cartridge when database access is needed. This eliminates the overhead of the LiveHTML cartridge instances and decreases the number of requests that must be processed by the WRB, increasing overall system performance.

You should use a different extension for LiveHTML files to let the listener distinguish them. You can easily configure the LiveHTML cartridge and the listener to recognize the specific LiveHTML extension.

The Java Cartridge

The Java cartridge, based on version 1.0.2 of the JDK, simply wraps the Java interpreter. This allows the instance-management characteristics of the Web Application Server to keep a minimum number of Java virtual machines loaded at all times, which provides obvious performance benefits. The Java cartridge is the most flexible of the Oracle cartridges in that it is easily extended by simply making Java public classes available via the CLASSPATH environment variable. Using the Java cartridge, you can write Web-enabled applications to access data and services from a wide range of sources, including other ORBs.

Several Java packages included with the Java cartridge provide support for generating dynamic HTML and accessing WRB services, including the intercartridge exchange. These packages include

  • oracle.html, which provides classes for creating dynamic content.
  • oracle.owas.orb.services.http, which provides classes for accessing URL parameters and CGI environment variables .
  • oracle.plsql, which contains classes that encapsulate the PL/SQL datatypes.
  • oracle.rdbms, which contains the Session class (which encapsulates an Oracle session).
  • Several other packages provide classes to encapsulate Oracle NLS parameters and WRB services.

Java applications have a number of options for communicating with the database, including the PL/SQL cartridge, JDBC or J/SQL, and custom JNI-OCI interfaces. Another option is the Java-PL/SQL Web Toolkit, included with Web Application Server and the Java cartridge. This interface provides the tightest integration between Java and PL/SQL by generating Java classes that wrap PL/SQL packages. Wrappers are generated using a supplied utility, pl2java.exe, which relies on an Oracle package that must be installed using the dbpkins.sql script. (This script is located in the $ORAWEB_HOME/java/sql/ directory.)

Page 199

The general use of pl2java.exe is illustrated by the following command line:

 pl2java  user/password@connect-string package1 package2 

You can use additional options to specify the Java package name , the destination directory, and so on. The output of pl2java is one Java source file per Oracle package specified, each containing a single class with the following characteristics:

  • The Java class name corresponds to the Oracle package name.
  • The class has a public constructor that accepts a oracle.rdbms.Session object.
  • The class has public methods that correspond to the Oracle package functions and procedures.
  • The datatypes of parameters and return values are Java classes defined in the oracle.plsql package that correspond to the appropriate PL/SQL datatypes.

The advantage to using these wrappers is that they completely encapsulate all interaction with the database. Consider the following code segment, which retrieves the values of parameters supplied to the URL and passes them to an Oracle stored procedure:

 HTTP request = HTTP.getRequest(); String deptno = request.getURLParameter("DEPTNO"); String dname = request.getURLParameter("DNAME"); String loc = request.getURLParameter("LOC"); PDouble p_deptno = new PDouble((new Double(p_deptno)),valueOf()); PStringBuffer p_dname = new PStringBuffer(dname); PStringBuffer p_loc = new PStringBuffer(loc); oracle.rdbms.Session connect =         new oracle.rdbms.Session("scott", "tiger", "orcl"); DEPTPACK packref = new DEPTPACK(connect); packref.INSERT(p_deptno, p_dname, p_loc); 

In this code segment, the DEPTPACK object is constructed using a Session object, at which point its methods that correspond to the Oracle package methods are invoked directly. The preceding segment also demonstrates the minor inconvenience of converting the URL parameters to the appropriate datatypes. Note that PDouble corresponds to an Oracle NUMBER, and PStringBuffer corresponds to an Oracle CHAR, VARCHAR, VARCHAR2, or LONG type. The Oracle package used to generate the Java class might be declared as

 CREATE PACKAGE DEPTPACK AS     PROCEDURE INSERT(deptnoin IN NUMBER, dnamein IN CHAR, locin IN CHAR); 

A Java cartridge URL is similar to a PL/SQL cartridge URL, having the general form of

 http://hostname.domain:port/virtual_path/classname 

Note that the virtual path specifies maps to the physical directory where the class resides, and the class name specifies the class containing the main() entry point. The preceding example might be invoked with a URL similar to the following:

 http://www.acme.com:2222/java/insdept?DEPTNO=6&DNAME=IS&LOC=NEW+YORK 
Previous Table of Contents Next


Oracle Unleashed
Oracle Development Unleashed (3rd Edition)
ISBN: 0672315750
EAN: 2147483647
Year: 1997
Pages: 391

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net