Building a simple webpage using Embedded PL/SQL Gateway
-- Create a demo user
create user demo_user identified by demo_user default tablespace users temporary tablespace temp;
grant connect,resource to demo_user;
-- Dynamic Authentication
-- Create a DAD (Database Access Descriptor)
conn /@testdb as sysdba
EXEC DBMS_EPG.CREATE_DAD('DEMO_DAD','/demo/*');
-- Set DAD attributes
EXEC DBMS_EPG.SET_DAD_ATTRIBUTE('DEMO_DAD','database-username','demo_user');
-- Set the Oracle XML DB HTTP port to the specified port number
EXEC DBMS_XDB.SETHTTPPORT(8088);
-- Get various status of the embedded PL/SQL gateway and the XDB HTTP listener.
@?/rdbms/admin/epgstat.sql
+--------------------------------------+
| XDB protocol ports: |
| XDB is listening for the protocol |
| when the protocol port is non-zero. |
+--------------------------------------+
HTTP Port FTP Port
--------- --------
8088 0
1 row selected.
+---------------------------+
| DAD virtual-path mappings |
+---------------------------+
Virtual Path DAD Name
-------------------------------- --------------------------------
/demo/* DEMO_DAD
1 row selected.
+----------------+
| DAD attributes |
+----------------+
DAD Name DAD Param DAD Value
------------ ------------------------ ----------------------------------------
DEMO_DAD database-username demo_user
1 row selected.
+---------------------------------------------------+
| DAD authorization: |
| To use static authentication of a user in a DAD, |
| the DAD must be authorized for the user. |
+---------------------------------------------------+
no rows selected
+----------------------------+
| DAD authentication schemes |
+----------------------------+
DAD Name User Name Auth Scheme
-------------------- -------------------------------- ------------------
DEMO_DAD demo_user Dynamic Restricted
1 row selected.
+--------------------------------------------------------+
| ANONYMOUS user status: |
| To use static or anonymous authentication in any DAD, |
| the ANONYMOUS account must be unlocked. |
+--------------------------------------------------------+
Database User Status
--------------- --------------------
ANONYMOUS EXPIRED & LOCKED
1 row selected.
+-------------------------------------------------------------------+
| ANONYMOUS access to XDB repository: |
| To allow public access to XDB repository without authentication, |
| ANONYMOUS access to the repository must be allowed. |
+-------------------------------------------------------------------+
Allow repository anonymous access?
----------------------------------
false
1 row selected.
-- Create a demo webpage
create or replace procedure demo_user.hello_world
is
begin
htp.p('<center><font size="6" color="blue">Hello World!<font></center>');
end;
/
-- Launch the webpage specifying username and password
http://127.0.0.1:8088/demo/hello_world
-- You can drop the DAD along with its virtual-path mappings using DBMS_EPG.DROP_DAD procedure.
exec DBMS_EPG.DROP_DAD('DEMO_DAD');
[Reference]
http://docs.oracle.com/cd/E11882_01/appdev.112/e41502/adfns_web.htm#ADFNS0151