Oracle JavaServer Pages Developer's Guide and Reference Release 8.1.7 Part Number A83726-01 |
|
This section is an overview of extended programming features supported by OracleJSP.
OracleJSP provides the following extended functionality through custom tag libraries and custom JavaBeans, all of which are portable to other JSP environments:
OracleJSP also provides the following Oracle-specific extensions:
JspScopeListener
for event handling
globals.jsa
file for application support
Discussion of these topics is followed by a brief description of how OracleJSP pages can interact with Oracle PL/SQL Server Pages.
The Oracle extensions discussed in this section are implemented either through the OracleJSP JML sample tag library or through custom JavaBeans. They are portable to other JSP environments.
JSP pages generally rely on core Java datatypes in representing scalar values. Neither of the following standard approaches to this is fully suitable for use in JSP pages:
int
, float
, and double
java.lang
package, such as Integer
, Float
, and Double
Primitive values cannot have a specified scope--they cannot be stored in a JSP scope object (for page
, request
, session
, or application
scope), because only objects can be stored in a scope object.
Wrapper type values are objects, so they can theoretically be stored in a JSP scope object. However, they cannot be declared in a jsp:useBean
action, because the wrapper classes do not follow the JavaBean model and do not provide a zero-argument constructor.
Additionally, instances of the wrapper classes are immutable. To change a value, you must create a new instance and assign it appropriately.
To work around these limitations, OracleJSP provides the JmlBoolean
, JmlNumber
, JmlFPNumber
, and JmlString
JavaBean classes in package oracle.jsp.jml
to wrap the most common Java datatypes.
See "JML Extended Datatypes" for more information.
You can use JSP syntax to generate any text-based MIME type, not just HTML code. In particular, you can dynamically create XML output. When you use JSP pages to generate an XML document, however, you often want a stylesheet applied to the XML data before it is sent to the client. This is difficult in JavaServer Pages technology, because the standard output stream used for a JSP page is written directly back through the server.
OracleJSP provides special tags in its sample JML tag library to specify that all or part of a JSP page should be transformed through an XSL stylesheet before it is output. You can use this JML tag multiple times in a single JSP page if you want to specify different style sheets for different portions of the page. Note that the JML tag library is portable to other JSP environments.
In addition, the OracleJSP translator supports XML-alternative syntax as specified in the Sun Microsystems JavaServer Pages Specification, Version 1.1.
See "OracleJSP Support for XML and XSL" for more information.
OracleJSP supplies a set of custom JavaBeans for use in accessing an Oracle database. The following beans are provided in the oracle.jsp.dbutil
package:
ConnBean
opens a simple database connection.
ConnCacheBean
uses Oracle's connection caching implementation for database connections.
DBBean
executes a database query.
CursorBean
provides general DML support for UPDATE
, INSERT
, and DELETE
statements, as well as queries.
See "Oracle Database-Access JavaBeans" for more information.
With release 8.1.7, OracleJSP provides a custom tag library for SQL functionality. The following tags are provided:
dbOpen
--Open a database connection.
dbClose
--Close a database connection.
dbQuery
--Execute a query.
dbCloseQuery
--Close the cursor for a query.
dbNextRow
--Move to the next row of the result set.
dbExecute
--Execute any SQL DML or DDL statement.
See "OracleJSP Tag Library for SQL" for more information.
Although the Sun Microsystems JavaServer Pages Specification, Version 1.1 supports scripting languages other than Java, Java is the primary language used and in many cases the only language considered. Even though JavaServer Pages technology is designed to separate the dynamic/Java development effort from the static/HTML development effort, it is no doubt still a hindrance if the Web developer does not know any Java, especially in small development groups where no Java experts are available.
OracleJSP provides custom tags as an alternative--the JSP Markup Language (JML). The Oracle JML sample tag library provides an additional set of JSP tags so that you can script your JSP pages without using Java statements. JML provides tags for variable declarations, control flow, conditional branches, iterative loops, parameter settings, and calls to objects.
The JML tag library also supports XML functionality, as noted previously.
The following example shows use of the jml:for
and jml:print
tags:
<jml:for id="i" from="1" to="5" > <H<jml:print eval="i" /> Hello World! </H<jml:print eval="i" /> </jml:for>
For more information, see "Overview of the JSP Markup Language (JML) Sample Tag Library".
Note: OracleJSP versions preceding the JSP 1.1 specification used an Oracle-specific compile-time implementation of the JML tag library. This implementation is still supported as an alternative to the standard runtime implementation. For information, see Appendix C, "Compile-Time JML Tag Support". |
The OracleJSP extensions listed in this section are not portable to other JSP environments.
Dynamic server pages commonly include data extracted from databases; however, JavaServer Pages technology does not offer built-in support to facilitate database access. JSP developers typically must rely on the standard Java Database Connectivity (JDBC) API or a custom set of database JavaBeans.
SQLJ is a standard syntax for embedding static SQL instructions directly in Java code, greatly simplifying database access programming. OracleJSP and the OracleJSP translator support SQLJ programming in JSP scriptlets.
SQLJ statements are indicated by the #sql
token. You can trigger the OracleJSP translator to invoke the Oracle SQLJ translator by using the file name extension .sqljsp
for the JSP source code file.
For more information, see "OracleJSP Support for Oracle SQLJ".
OracleJSP provides extended NLS support for servlet environments that cannot encode multibyte request parameters and bean property settings.
For such environments, OracleJSP offers the translate_params
configuration parameter, which can be enabled to direct OracleJSP to override the servlet container and do the encoding itself.
For more information, see "OracleJSP Extended Support for Multibyte Parameter Encoding".
OracleJSP provides the JspScopeListener
interface for lifecycle management of Java objects of various scopes within a JSP application.
Standard servlet and JSP event-handling is provided through the javax.servlet.http.HttpSessionBindingListener
interface, but this handles session-based events only. The Oracle JspScopeListener
can handle page-based, request-based, and application-based events as well.
For more information, see "OracleJSP Event Handling--JspScopeListener".
For servlet 2.0 environments, where servlet contexts are not fully defined, OracleJSP defines a file, globals.jsa
, to extend servlet application support.
Within any single Java virtual machine, there can be a globals.jsa
file for each application (or, equivalently, for each servlet context). This file supports the concept of Web applications through use as an application location marker. Based on globals.jsa
functionality, the OracleJSP container can also mimic servlet context and HTTP session behavior for servlet environments, where such behavior is not sufficiently defined.
The globals.jsa
file also provides a vehicle for global Java declarations and JSP directives across all JSP pages of an application.
Oracle provides a product called PL/SQL Server Pages (PSP). PSP technology allows embedded PL/SQL scriptlets and stored procedure calls within an HTML page, offering development advantages similar to those offered by JSP technology: namely, that coding the dynamic portion of the page and the static portion of the page can be largely separate development efforts. An HTML expert can code the static part of the page and a PL/SQL expert can code the dynamic part of the page. The syntax used to distinguish PL/SQL scriptlets in a PSP page is identical to that used to distinguish Java scriptlets in a JSP page.
The remainder of this section discusses support for JSP-PSP interaction, and includes some background on PSP URLs.
For general information about PL/SQL Server Pages, see the Oracle8i Application Developer's Guide - Fundamentals.
When an end-user runs a PSP application, PSP pages are translated into stored procedures for execution by the PL/SQL gateway in producing output to the Web browser. Because the PL/SQL gateway in Oracle8i executes in a servlet wrapper, JSP pages running in the Oracle Servlet Engine can interact with PSP pages as follows:
jsp:include
).
jsp:forward
).
However, PSP pages do not have the functionality to dynamically include or forward to a JSP page. Additionally, you cannot statically include a PSP page from a JSP page (the <%@ include %>
directive to include a file during translation).
Each PSP page, when loaded and compiled in the database, becomes a PL/SQL stored procedure. The name of the stored procedure for a PSP page is either explicitly declared in the page, using <%@ plsql procedure="proc-name" %>
syntax, or is derived from the name of the PSP file.
Given the name of the PL/SQL stored procedure, the URL is determined according to the following general syntax:
http://host[:port]/some-prefix/dad/[schema.]proc-name
Where <
some-prefix
>
is plsql
for the embedded PL/SQL module, and <
dad
>
is the database access descriptor to run the stored procedure.
For more information, see the Oracle8i Application Developer's Guide - Fundamentals.
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|