| Oracle JavaServer Pages Developer's Guide and Reference Release 8.1.7 Part Number A83726-01  | 
 
  | 
This section is an overview of considerations and logistics in deploying a JSP application into Oracle8i to run in the Oracle Servlet Engine. The following topics are covered:
Java code that executes in the Oracle Servlet Engine uses an Oracle8i JVM inside the database. The code must be loaded into a particular database schema as one or more schema objects.
The three kinds of schema objects for Java are:
Each schema object is an individual library unit in the database. When you query the ALL_OBJECTS table of the schema, Java schema objects are seen as type JAVA SOURCE, JAVA CLASS, or JAVA RESOURCE, respectively.
See the Oracle8i Java Developer's Guide for more information.
The JServer loadjava tool is used to load Java files into the database as schema objects. (See "Overview of the loadjava Tool".)
When you compile on the client and load the .class file directly, loadjava stores the .class file as a class schema object in the database.
When you load a resource file (such as a .res file for static JSP content or .ser profile file for SQLJ), loadjava stores the resource file as a resource schema object in the database.
When you load a .java (or .sqlj) source file, loadjava stores the source file as a source schema object in the database and optionally compiles it inside the database to create one or more class schema objects.
When you load a .jsp or .sqljsp page source file (for server-side translation), loadjava stores the page source as a resource schema object. During server-side translation (through the JServer session shell publishjsp command), server-side loadjava is invoked automatically to create source schema objects, class schema objects, and resource schema objects during translation and compilation.
(See "Tools and Commands for Translation and Deployment to Oracle8i" for an overview of the loadjava and session shell tools.)
The two forms of schema object names in Oracle8i are full names and short names.
Full names are fully qualified and are used as the schema object names wherever possible. If any full name contains more than 31 characters, however, or contains characters that are illegal or cannot be converted to characters in the database character set, then the Oracle8i server converts the full name to a short name to employ as the name of the schema object, keeping track of both names and how to convert between them. If the full name contains 31 characters or less and has no illegal or inconvertible characters, then the full name is used as the schema object name.
For more information about these and about other file naming considerations, including DBMS_JAVA procedures to retrieve a full name from a short name and a short name from a full name, see the Oracle8i Java Developer's Guide.
During loading of Java files into the database, the loadjava tool uses the following logic to determine the package for Java schema objects it creates:
.java and .sqlj files) and class schema objects (created from .class files or by compiling .java files), the schema package is determined by any package information in the Java code.
For example, a class Foo that specifies the package dir1.dir2 and is being loaded into the SCOTT schema will be stored in the schema as follows:
SCOTT:dir1/dir2/Foo
.res and .ser Java resource files, for example), the schema package is determined by any path information in the loadjava command line (if the Java resource file is being loaded directly) or the JAR file (if the Java resource file is being loaded as part of a JAR file).
For example, a .res file being loaded into the SCOTT schema as dir3/dir4/abcd.res will be stored in a schema object as follows:
SCOTT:dir3/dir4/abcd.res
Any JSP page (or servlet) that will run in the Oracle Servlet Engine must be "published", a process that makes its executable Java code (the class schema objects) accessible through entries in the JServer JNDI namespace.
Publishing the JSP page links its page implementation class schema object to a servlet path (and optionally to a non-default servlet context path). The servlet path (and context path, if applicable) becomes part of the URL that an end-user would specify to access and execute the page. See "URLs for the Oracle Servlet Engine" for more information.
To publish a JSP page, use the Oracle8i session shell publishjsp command for the "deployment with server-side translation" scenario, or the session shell publishservlet command for the "deployment with client-side translation" scenario. See "Translating and Publishing JSP Pages in Oracle8i (Session Shell publishjsp)" or "Publishing Translated JSP Pages in Oracle8i (Session Shell publishservlet)".
JSP pages and servlets running in the Oracle Servlet Engine are typically accessed through the Oracle HTTP Server (powered by Apache) and its mod_ose module, although it is possible to use OSE itself as the Web server.
For more information about the role of the Oracle HTTP Server and mod_ose, see "Role of the Oracle HTTP Server, Powered by Apache".
As with servlet URLs in general, URLs to invoke JSP pages running in the Oracle Servlet Engine are formed by a combination of two components (in addition to the hostname and port):
The context path for the OSE default context, /webdomains/contexts/default, is simply:
/
The context path for any other OSE servlet context you create, which you accomplish using the Oracle8i session shell createcontext command, is whatever you specify in the createcontext -virtualpath option. (It is conventional, but not required, to specify that the context path be the same as the context name.)
For general information about the session shell createcontext command, see the Oracle8i Java Tools Reference. For an overview of the Oracle8i session shell, see "Overview of the sess_sh Session Shell Tool".
The servlet path (JSP page "virtual path") is determined by how you publish the JSP page, as follows:
publishjsp command (for server-side translation), then it is determined by the publishjsp -virtualpath option, or else is the same as the specified schema path by default.
publishservlet command (after client-side translation), then it is determined by the publishservlet -virtualpath option (which you must specify when you use publishservlet for a JSP page).
See "Translating and Publishing JSP Pages in Oracle8i (Session Shell publishjsp)" or "Publishing Translated JSP Pages in Oracle8i (Session Shell publishservlet)".
As an example, consider a JSP page that is published to the OSE default context with a servlet path (virtual path), as follows:
mydir/mypage.jsp
This page is accessed as follows:
http://host[:port]/mydir/mypage.jsp
You can access it from another page in the application, say mydir/mypage2.jsp, in either of the following ways (the first is a page-relative path; the second is an application-relative path):
<jsp:include page="mypage.jsp" flush="true" /> <jsp:include page="/mydir/mypage.jsp" flush="true" />
Now consider a servlet context that is created as follows ($ is the session shell prompt):
$ createcontext -virtualpath mycontext /webdomains mycontext
This does the following:
/webdomains/contexts/mycontext (all servlet contexts in the /webdomains domain go under /webdomains/contexts). 
mycontext).
If mydir/mypage.jsp is published to the mycontext servlet context, it is accessed as follows:
http://host[:port]/mycontext/mydir/mypage.jsp
You can access it from another page in the application, say mydir/mypage2.jsp, in either of the following ways (the first is a page-relative path; the second is an application-relative path):
<jsp:include page="mypage.jsp" flush="true" /> <jsp:include page="/mydir/mypage.jsp" flush="true" />
The syntax for the dynamic jsp:include statements is the same as in Example 1. Even though a different servlet context is used, the path of the pages relative to the context is unchanged.
Now consider a servlet context that is created as follows ($ is the session shell prompt):
$ createcontext -virtualpath mywebapp /webdomains mycontext
This does the following:
/webdomains/contexts/mycontext as in Example 2.
mywebapp, that is different from the context name. It is this context path, not the context name, that is used in the URL.
In this case, if mydir/mypage.jsp is published to the mycontext servlet context, it is accessed as follows:
http://host[:port]/mywebapp/mydir/mypage.jsp
You can access it from another page in the application, say mydir/mypage2.jsp, in either of the following ways (the first is a page-relative path; the second is an application-relative path):
<jsp:include page="mypage.jsp" flush="true" /> <jsp:include page="/mydir/mypage.jsp" flush="true" />
This section describes the required placement of static files, such as HTML files, that are used in a JSP application that runs in the Oracle Servlet Engine.
The information in this section is independent of whether the Oracle HTTP Server (powered by Apache) is used as a front-end Web server for OSE, or OSE is used directly.
Static files that are dynamic include or forward targets (jsp:include or jsp:forward) in a JSP application running in the Oracle Servlet Engine must be manually moved or copied to the OSE doc root directory corresponding to the servlet context of the application. When you create an OSE servlet context (using the session shell createcontext command), you specify a doc root directory through the createcontext -docroot option. Each OSE doc root directory is linked to the JServer JNDI namespace.
OSE doc root directories are outside the database. The JNDI lookup mechanism for static files is a front-end for the file system of the server where the database resides.
The doc root for the OSE default servlet context, /webdomains/contexts/default, is the following:
$ORACLE_HOME/jis/public_html
Whenever you create an additional servlet context with the session shell createcontext command, you can use the createcontext -docroot option to specify a doc root directory. (For more information about the session shell createcontext command, see the Oracle8i Java Tools Reference.)
Any file that is statically included (through an include directive) by a JSP page, whether it is another JSP page or a static file such as an HTML file, must be accessible by the OracleJSP translator during translation. 
In the case of a JSP application targeted for OSE, there are two translation scenarios:
This is where you load a .jsp file into the database as a Java resource, then use publishjsp to invoke the OracleJSP translator in the server. (See "Deployment to Oracle8i with Server-Side Translation".)
In this case, static files must be loaded into the database beforehand, using loadjava, as resource schema objects.
This is where you translate a .jsp file on the client using ojspc and load the generated components into the database.
In this case, static files do not have to be in the server at all. They only have to be accessible by ojspc on the client during translation. (For application-relative static include directives, see the discussion of the ojspc -appRoot option under "Option Descriptions for ojspc".)
Developers who are deploying their JSP pages to Oracle8i to run in the Oracle Servlet Engine can translate either in the server or on the client.
Deployment with server-side translation requires two steps:
loadjava to load the JSP page source (.jsp or .sqljsp file) into Oracle8i as a resource schema object. (You must also load any required Java classes or other required JSP pages.)
publishjsp command. This will automatically accomplish the following: 
publishjsp -hotload option).
This step also produces source schema objects, class schema objects, and resource schema objects for all generated .java files (and .sqlj files for .sqljsp pages), .class files, and resource files, respectively.
See "Deployment to Oracle8i with Server-Side Translation" for more information.
Deployment with client-side translation requires three or, optionally, four steps:
ojspc. This accomplishes the following:
ojspc first produces a SQLJ source file then invokes the SQLJ translator to produce Java code.)
ojspc -extres and -hotload options.
loadjava utility to load the class files and any resource files into Oracle8i as class schema objects and resource schema objects.
ojspc -hotload option during translation) by using the Oracle8i session shell java command to execute the main() method of the page implementation class.
publishservlet command to publish the page implementation classes for execution in the database.
See "Deployment to Oracle8i with Client-Side Translation" for more information.
If you are using Oracle JDeveloper, you may find it more convenient to translate on the client using the OracleJSP translator provided with JDeveloper and then deploy the resulting classes and resources, as in steps 2, 3, and 4.
If you are not using JDeveloper, however, translating in the server is likely to be more convenient, because the session shell publishjsp command combines translation, optional hotloading, and publishing into a single step.
In addition, either of the following situations may dictate the need to translate in the server:
Oracle8i JServer offers a feature known as hotloading classes, for more efficient use of static final variables (constants). This becomes relevant whenever the hotloaded classes might be used by multiple concurrent users.
A separate JVM is invoked for each JServer database session. Normally each session gets its own copy of all static final variables in its session space or, in the case of literal strings, in a hashtable known as the intern table in shared memory. Use of literal strings in the intern table is synchronized across sessions.
The processing of literal strings is especially relevant to JSP pages. By default (without hotloading), the static text in a JSP page is ultimately represented as literal strings.
| 
 Note: 
This section refers to the OracleJSP pre-translation tool (  | 
The ability to hotload a JSP page is enabled during translation, through the ojspc -hotload option (for client-side translation) or the publishjsp -hotload option (for server-side translation). 
Enabling the -hotload option directs the OracleJSP translator to do the following:
main() method that invokes the hotloading method.
The hotloading itself is accomplished as follows:
ojspc -hotload option enabled and loading the page into the database, and before publishing the page, you must use the session shell java command to invoke the main() method of the page implementation class. Details of the process are discussed in "Deployment to Oracle8i with Client-Side Translation".
publishjsp functionality when you enable the publishjsp -hotload option.
The act of hotloading a page implementation class, either directly through the session shell java command or indirectly through the publishjsp command, actually just makes the inner class static text shareable among multiple JVMs in the database.
Hotloading classes results in the following logistical features and advantages:
char arrays representing static text.
char arrays only once. 
These char arrays, instead of being stored in the synchronized intern table, are stored elsewhere in a global area that is shared across all sessions without synchronization (which is feasible because of the knowledge that none of the variables will change).
Hotloading, by avoiding synchronization and other costly overhead, can significantly improve the runtime performance and scalability of JSP pages executed in the Oracle Servlet Engine. Furthermore, when a hotloaded class is referenced, the class initializer is not rerun. The session has instant access to the literal strings and other static final variables.
In addition to allowing better performance of individual JSP pages, hotloading reduces overall CPU usage of the server.
| 
 | 
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved.  | 
 
  |