Web applications and Oracle FIS 432/632
Intranets, Extranets, and the Internet
The Ideal Client
The Five Ways of Building Oracle Web Applications • Java Servlets (and Java Server Pages)• PL/SQL Stored Procedures (and PL/SQL Server Pages) • Designer PL/SQL Web Generator • Oracle 9i Application Server Portal (previously called WebDB) • Oracle Developer (Forms and Reports)
Java Servlets • The user requests a Web page (by typing in a URL, clicking a link, or pressing a button). • The Apache HTTP server determines that the request is for a Java servlet and passes the request to the mod_jserv module. • The mod_jserv module passes the request to the JServ servlet engine.• The JServ servlet engine loads the requested servlet, creates a request object, which includes all the information from the request, and a response object, and passes both to the servlet. • The servlet class executes, using JDBC to connect to the database if necessary. It writes the output to the response object.
Advantages and Disadvantages Advantages Disadvantages J a va is a m ore m ode rn a nd Ne w la ng ua g e to le a rn for fe a ture -ric h prog ra m m ing m a ny Ora c le de ve lope rs la ng ua g e th a n P L/S QL J a va S e rvle ts a re not bound Ne e d m uc h c ode (J DB C ) or to a s pe c ific ve ndor non-s ta nda rd fe a ture s (S QLJ ) to re trie ve da ta from da ta ba s e S ome ove rh e a d in e s ta blis h ing a da ta ba s e c onne c tion
PL/SQL Web Applications
PL/SQL Web Applications • The user requests a Web page by typing in a URL, clicking a linkor pressing a button. • The Apache HTTP server determines that the request is for a PL/SQL stored procedure and passes it to mod_plsql. • The mod_plsql module uses the information in the URL along with the configuration information in the Database Access Descriptor to determine to which Oracle user in which database it should connect. It then invokes the procedure in the database. • The stored procedure runs, using the procedures in the HTTP package to write output in a buffer. • The mod_plsql module returns the output in the buffer through the Apache HTTP server to the Web browser.
Advantages and Disadvantages Advantages Disadvantages With in th e lim ita tions of Al c ode is h a nd-writte n HTML, ”e ve ryth ing ” is (Doc um e nta tion? pos s ible Ma inta ina bility? Qua lity? ) E a s y a nd fa s t to s e t up La c k of inte g ra te d tools :1) Write HTML in HTML tool2) Conve rt to P L/S QL Le ve ra g e s e xis ting P L/S QL 3) Add bus ines s logic in a s kil s P L/S QL tool
Oracle Designer • Normal PL/SQL Web applications, i.e. HTML-based • Desired functionality is modelled in the Designer tools together with the data model • Designer PL/SQL Web Generator produces PL/SQL code from the model
Advantages and Disadvantages Advantages Disadvantages Hig h qua lity doc um e nta tion S te e p le a rning c urve g e ne ra te d a utom a tic a l y Hig h m a inta ina bility Diffic ult to c ontrol th e g e ne ra te d a pplic a tion th roug h pre fe re nc e s a nd te m pla te s Option to c h a ng e front e nd S ome lim ita tions to th e (F orm s , P L/S QL We b, ma ybe a pplic a tions pos s ible J a va ? )
Oracle Portal • HTML-based (using PL/SQL)• Browser-based: All development work is done in the browser with Wizards • Portal generates PL/SQL stored procedures making extensive use of special Portal packages
Advantages and Disadvantages Advantages Disadvantages F a s t a nd e a s y – P owe r us e rs S tric tly lim ite d to th e c a n de ve lop s m a l a pps func tiona lity offe re d by th e P orta l wiz a rds No c lie nt ins ta l a tion ne e de d No doc um e nta tion (a nd no pla c e to put doc um e nta tion in th e c ode ) Als o doe s s ite m a na g e m e nt a nd s om e ba s ic DB A func tions
Oracle Forms: Getting the Forms Applet to the User
Oracle Forms: Getting the Forms Applet to the User • The user requests the first Web page of the application.• The Apache HTTP server determines that the request is for a CGI program and passes the request to the mod_cgi module. • The mod_cgi module starts the Forms CGI program.• The Forms CGI program produces an HTML page with an instruction to load the Forms applet. • The HTML page is passed back to the Web browser through the mod_cgi module and the HTTP server. • The Web browser automatically requests the Forms applet from the HTTP server (and possibly the JInitiator Java plug-in). • The HTTP server delivers the Forms applet (and JInitiator) to the Web browser, that starts the JVM and the applet.
Oracle Forms: Running a Web Forms Application
Oracle Forms: Running a Web Forms Application • The Forms applet contacts the Forms Listener to start a session. This connection does not involve the Apache HTTP server in any way—it goes straight from the applet to the Forms Listener. • The Forms Listener starts a Forms Runtime Engine for that client. • The Forms Runtime Engine establishes a connection to the database and to the client applet.
Advantages and Disadvantages Advantages Disadvantages F ul c ontrol ove r th e us e r Ne e ds a s pe c ific J a va Virtua l inte rfa c e Ma c h ine (IE 5 or s e pa ra te plug -in to downloa d) Le ve ra g e e xis ting F orm s s kil s Long e r s ta rtup tim e (a pple t downloa d, J VM initia liz a tion) Obvious firs t m ig ra tion pa th Ne e ds m ore h a rdwa re for Clie nt/S e rve r a pplic a tions (S e rve r: 10+ MB R AM pe r c lie nt, C lie nt: 64+ MB R AM)
Oracle Reports • The user requests the report by typing in a URL or clicking a link.• The HTTP server passes the request to the mod_cgi module. • The mod_cgi module invokes the Reports CGI program.• The Reports CGI or servlet reformats the request and passes it on to the Reports Server. • The Reports Server checks whether the desired report already exists in the report cache. If the report is not in the cache, the Reports Server assigns the report to the next available Reports Runtime Engine. • The Reports Runtime Engine connects to the database, retrieves and formats the data, and writes the report in the cache. • The Reports Server instructs the requesting Web browser to pick up the report through the HTTP server. • The Web browser requests the report from the Web server.• The Web server delivers the report.
Advantages and Disadvantages Advantages Disadvantages F a milia r tool Complica te d to control la yout P roductive wiz a rds Choice of output forma ts : HTML, HTML with CS S , P DF
Choose Your Weapon • Who will be using your application? Intranet, extranet, Internet users? • How complex is the user interface you need?
Building Applet-Based Applications • Using Web Forms• Using Java applets
Building HTML-Based Applications • What language skills do your developers have? • Is it important to be independent of Oracle?
Generating Applications If yo u c a n liv e w ith th e us e r in te rfa c e th e y o ffe r, Ora c le s c o d e – g e n e ra tin g to o ls a l o w m uc h h ig h e r d e v e lo pe r pro d uc tiv ity • Oracle Portal is fully browser-based: The application developer defines the application by filling in fields in a form • Oracle Designer is a full-featured CASE tool: The developer uses a number of development tools that work against a common repository storing a model of your application.
Could I Have That in Writing? • Printing from Java applets is tedious (and is for security reasons disabled by default) • Printing from HTML gives only rudimentary control over the appearance of the printed page. • PDF format allows you to produce good-looking reports in a Web browser and on paper • Oracle Reports can produce reports in both HTML and PDF
Summary • Heads-down users might need a Java applet application: Use Oracle Forms • Casual users and Internet users need an HTML-based application• Build HTML-based applications with Oracle Designer if you can• You can use either PL/SQL or Java for handwritten parts of HTML- based applications: – Ja v a is v e n d o r in d e pe n d e n t a n d o ffe rs th e a d v a n ta g e s o f m o d e rn o b je c t-o rie n te d pro g ra m m in g – PL/SQL o ffe rs un b e a ta b le pe rfo rm a n c e fo r d a ta b a s e – in te n s iv e a pplic a tio n s . • Portal is promising as integration point for all applications, but not a real alternative for application development
The Designer Approach • Computer-Aided Software Engineering• A Model stored in a Repository • Generates code at the push of a button• Many ways to use – Information Engineering– Rapid Application Development • Version Control possible
The Designer Tools
Building Applications with Designer Logical Data Data/Function Function Design Mapping Design Transform Transform Physical Table Table/Module Module Design Mapping Design Database PL/SQL Tables etc. packages
Building the Database When building the database, the end result is the same: tables in the database. But you have two ways of getting there: you can either start with an Entity-Relationship model in the E-R modeler or go directly to the Design Editor. Advantages Disadvantages Using the Focus on Several tools E-R Diagrammer logical design involved Using the Entire design Must code PK Design Editor in one step and FK columns
Design Capture • Reading the definition of existing database objects into the Repository • Making changes in Designer• Generating a script to implement the changes
Building an Employee List The hierarchy of objects: • Module• Module Component• Table Usage Context items:The columns appearing on the Record List
The Basic Employee List Without setting preferences and applying formatting, the application doesn’t look very appealing
Important Generator Preferences Name Description Value Comment MODSUB Substitute HTML No To allow HTML tags in user text Reserved Characters MODALR Startup Page: About No To remove the About link Page Hyperlink PKGLST PL/SQL Package List Format The HTML-generating pack-ages recognized by Designer MODSFA Standard Footer on All Yes Instruction to use footer Pages MODSFT Standard Footer format.pageEnd A call to the Format package MODSHA Standard Header on Yes Instruction to use header All Pages MODSHD Standard Header format.pageStart(‘ A call to the Format package Module Title’)
Formatted Employee List Using a format package and a standard preference set improves the look
Adding a Query Form • Appears automatically if any items are queryable• Intelligent date interval• Oracle interMedia Text querying
The Query Form for the Employee List From and To date with pop-up calendar
Maintain Employees • Continue your work on a copy• Add insert, update, delete functionality to the module component • Define operations on bound items
Building an Employee List The hierarchy of objects: • Module• Module Component• Table Usage• Lookup tables
Employee Detail with Lookup Department name comes from lookup table Manager name selected via List-of-Values
Multi-Record View Forms Multi-record View Forms are a Designer6i feature
Master-Detail Web Page