Previous | Table of Contents | Next |
A few other points to notice:
Tip:
If you want to incorporate client-side JavaScript in your application, you have two choices. You can embed the actual JavaScript in the PL/SQL procedures to write the HTML outputin other words, write JavaScript code into the HTML file. Or you can store the JavaScript code in separate files on the server, and use HTML tags to reference the files. This second method is actually easier if you want to debug and modify the JavaScript without having to recompile your packages and procedures.
Oracle provides a series of other packages to deal with the special Web-related issues of a PL/SQL Web application. Several are described in Table 27.4.
Package | Description |
---|---|
OWA_COOKIE | For sending, receiving, and managing cookies. |
OWA_ICX | Procedures for the Inter-Cartridge Exchange. |
OWA_IMAGE | Image map handling. |
OWA_OPT_LOCK | Locking records, obtaining ROWIDs, and so forth to implement an optimistic locking model. |
OWA_PATTERN | Provides some Perl-like text pattern matching features to support the conversion of Perl scripts into PL/SQL stored procedures. |
OWA_SEC | Procedures to deal with security features. |
OWA_UTIL | Very useful package that includes various utilities, including those that get CGI environment variables, generate MIME type responses, redirect URLs, print preformatted tables of data, and so forth. Lets you deal directly with HTTP. |
Stored Procedures and Cookies
Since users who log in to the Web are not necessarily using Oracle schema names (see the discussion on Security), you cannot use the USER pseudo-column to identify your users. Furthermore, HTTP is stateless; login sessions do not exist on the Web as they do on a client-server system (see the earlier discussion on Cookies). So how can you identify who a user is when a procedure is invoked?
One approach is to build some extra functionality into the login process. When users log in, create a cookiesome lengthy number you create internally will work (you could use a SEQUENCE). Using the OWA_COOKIE package, you download this number to the users client, the number is stored on their machine and you keep a copy of it in an internally stored Web session table. You can also use the OWA_SEC and OWA_UTIL packages to confirm the users physical IP address at the time of log in, and store that in the Web session table with the cookie number, along with any user specific runtime options relevant to the application.
After that, any procedure that the client requests could include a cookie check (using OWA_COOKIE) to do the following:
A check to a procedure like this should occur at the beginning of every single stored procedure that needs to know who the user is.
In this fashion, cookies can be used to maintain a record of a users transactions across several procedure calls, as in the shopping cart application used by many Web stores.
Previous | Table of Contents | Next |