Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
41
Добавлен:
16.04.2013
Размер:
4.96 Mб
Скачать

PL/SQL Web Toolkit

Once mod_plsql is logged in, authentication control is passed back to the application, by calling an application-level PL/SQL hook. This callback function is implemented by the application developers. The value returned by the callback function determines whether authentication succeeds or fails: TRUE means success; FALSE means failure.

Depending on what kind of custom authentication is desired, you can place the authentication function in different locations:

Global OWA invokes the same authentication function for all users and all procedures.

Custom OWA invokes a different authentication function for each user and for each procedure.

Individual-Package OWA invokes the same authentication function for all users, but only for anonymous procedures or procedures in a specific package.

For example, using Custom OWA, an authorization function might verify that a user has logged in as user guest with password welcome, or it might check the user's IP address to determine access.

See Also: mod_plsql User's Guide

PL/SQL Web Toolkit

To develop the stored procedures that are executed by PL/SQL Gateway at runtime, you use PL/SQL Web Toolkit: a set of PL/SQL packages that can be used to obtain information about an HTTP request; specify HTTP response headers, such as cookies, content-type, and mime-type, for HTTP headers; set cookies; and generate standard HTML tags for creating HTML pages.

Commonly used PL/SQL Toolkit packages are listed in Table 13–1.

Table 13–1 Some Packages in PL/SQL Toolkit

Package

Description

 

 

htp

htp (Hypertext Procedures) package – Procedures that

 

generate HTML tags. For instance, the procedure htp.anchor

 

generates the HTML anchor tag, <A>.

htf

htf (Hypertext Functions) package– Function versions of the

 

procedures in the htp package. The function versions do not

 

directly generate output in a Web page. Instead, they pass their

 

output as return values to the statements that invoke them. Use

 

these functions when you need to nest function calls.

13-6 Oracle Database Application Developer's Guide - Fundamentals

 

 

PL/SQL Web Toolkit

 

 

 

 

Table 13–1 (Cont.)

Some Packages in PL/SQL Toolkit

 

 

 

 

Package

Description

 

 

 

 

owa_cache

Functions and procedures that enable the PL/SQL Gateway

 

 

cache feature, to improve the performance of your PL/SQL

 

 

Web application.

 

 

You can use this package to enable expires-based and

 

 

validation-based caching using the PL/SQL Gateway file

 

 

system.

 

owa_cookie

Subprograms that send and retrieve HTTP cookies to and from

 

 

a client Web browser. Cookies are strings a browser uses to

 

 

maintain state between HTTP calls. State can be maintained

 

 

throughout a client session or longer if a cookie expiration date

 

 

is included.

owa_custom

owa_image

The authorize function used by cookies. See "Uploading and Downloading Files With PL/SQL Gateway".

Subprograms that obtain the coordinates where a user clicked an image. Use this package when you have an image map whose destination links invoke a PL/SQL Gateway.

owa_opt_lock

owa_pattern

owa_sec

owa_text

owa_util

Subprograms that impose database optimistic locking strategies, to prevent lost updates.

Lost updates can otherwise occur if a user selects, and then attempts to update, a row whose values have been changed in the meantime by another user.

Subprograms that perform string matching and string manipulation with regular expression functionality.

Subprograms used by the PL/SQL Gateway for authenticating requests.

Subprograms used by package owa_pattern for manipulating strings. You can also use them directly.

Utility subprograms:

Dynamic SQL utilities to produce pages with dynamically generated SQL code.

HTML utilities to retrieve the values of CGI environment variables and perform URL redirects.

Date utilities for correct date-handling. Date values are simple strings in HTML, but must be properly treated as an Oracle Database datatype.

Developing Web Applications with PL/SQL 13-7

Generating HTML Output from PL/SQL

Table 13–1 (Cont.)

Some Packages in PL/SQL Toolkit

 

 

Package

Description

 

 

wpg_docload

Subprograms that download documents from a document

 

repository that you define using the DAD configuration. See

 

"Uploading and Downloading Files With PL/SQL Gateway".

 

 

See Also:

PL/SQL Packages and Types Reference

Generating HTML Output from PL/SQL

Traditionally, PL/SQL Web applications have used function calls to generate each HTML tag for output, using the PL/SQL Web toolkit packages that come with Oracle Database:

owa_util.mime_header('text/html');

htp.htmlOpen;

htp.headOpen;

htp.title('Title of the HTML File'); htp.headClose;

htp.bodyOpen( cattributes => 'TEXT="#000000" BGCOLOR="#FFFFFF"'); htp.header(1, 'Heading in the HTML File');

htp.para;

htp.print('Some text in the HTML file.'); htp.bodyClose;

htp.htmlClose;

You can learn the API calls corresponding to each tag, or just use some of the basic ones like HTP.PRINT to print the text and tags together:

htp.print('<html>');

htp.print('<head>');

htp.print('<meta http-equiv="Content-Type" content="text/html">'); htp.print('<title>Title of the HTML File</title>'); htp.print('</head>');

htp.print('<body TEXT="#000000" BGCOLOR="#FFFFFF">'); htp.print('<h1>Heading in the HTML File</h1>'); htp.print('<p>Some text in the HTML file.'); htp.print('</body>');

13-8 Oracle Database Application Developer's Guide - Fundamentals

Соседние файлы в папке Oracle 10g