web databse interfacing

35
2-1 WEB DATABSE INTERFACING Colorado Technical University IT420

Upload: morse

Post on 24-Jan-2016

28 views

Category:

Documents


0 download

DESCRIPTION

WEB DATABSE INTERFACING. Colorado Technical University IT420. Web Database Software. HTTP - (Hyper Text Transfer Protocol) an application level protocol supporting platform-independent communications. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: WEB DATABSE INTERFACING

2-1

WEB DATABSE INTERFACING

Colorado Technical University

IT420

Page 2: WEB DATABSE INTERFACING

2-2

Web Database Software

• HTTP - (Hyper Text Transfer Protocol) an application level protocol supporting platform-independent communications.

• URL - (Uniform Resource Locator) naming mechanism used by HTTP clients to access data - Contain:– Retrieval protocol, Internet node desired– File System directory, File name of resource to be

served

Page 3: WEB DATABSE INTERFACING

2-3

Web Database Software contd.

• URL’s provide the naming scheme and location as well as the protocol needed to access the desired resource.

• HTML - (Hyper Text Markup Language) hypertext and links combined into an ASCII text document that can be read by a Internet Browser.

• The WEB has created the worlds largest set of “spaghetti code” to exist.

Page 4: WEB DATABSE INTERFACING

2-4

Web Appeal

• The main appeal for the Web consists of two capabilities of the HTTP protocol:– Capability to transfer complex data types.– Ability to communicate among HTTP clients

and other protocols using different gateways, e.g gopher, SMTP, etc.

Page 5: WEB DATABSE INTERFACING

2-5

HTML PAGE CONSTRUCT

• All HTML pages must make use of the following three tags:

• <HTML> Indicates that this is an HTML file. Format is as follows:

• <HTML>

• …your page…

• </HTML>

Page 6: WEB DATABSE INTERFACING

2-6

HTML PAGE CONSTRUCT - Cont’d

• <HEAD> Used to specify the prologue of the file. Usually, only a title is placed in the head tag. Format is as follows:

• <HTML>

• <HEAD>

• <TITLE>This is the title.</TITLE>

• </HEAD>

• ………...

• </HTML>

Page 7: WEB DATABSE INTERFACING

2-7

HTML PAGE CONSTRUCT - Cont’d

• <BODY> Used to bound remaining part of HTML document, e.g. text, links, JPGs, etc. Format is as follows:

• <HTML>

• <HEAD>

• <TITLE>This is the title.</TITLE>

• </HEAD>

• <BODY>

• ………...

• </BODY>

• </HTML>

Page 8: WEB DATABSE INTERFACING

2-8

Incorrect Nesting

• <HTML>

• <HEAD>

• <BODY>

• </HEAD>

• </BODY>

• </HTML>

Page 9: WEB DATABSE INTERFACING

2-9

HTML TITLE

• The <TITLE> tag is used to identify what the page describes.

• This tag will also be used if someone saves the page as a bookmark.

• Title can only contain plain text (No special markups allowed).

• Since title is displayed in your browser, make it short so that it fits.

Page 10: WEB DATABSE INTERFACING

2-10

HEADINGS

• Headings are used to divide sections of text.

• A maximum of six levels of headings can be used.

• Headings are of the form – <H1>– Heading Text– </H1>

Page 11: WEB DATABSE INTERFACING

2-11

Heading Examples

If you take a laptop computer for a run,you could jog your memory.Pocket computers were invented for those who likesmall talk.

A computer store takes inventory to monitor progress including a diskcount.

Buying a cheap mouse could leave you with a squeak and a sad tale.

Whether you use a keyboard or a knife, be careful with your back slash.

When your internet provider goes bankrupt, it's a 'net' loss.

Page 12: WEB DATABSE INTERFACING

2-12

Paragraphs

• Paragraphs markers are used to indicate the beginning and end of a paragraph. Markers are as follows:– <P>– paragraph text– </P>– The closing tag </P> is optional. The opening

tag <P> is required.

Page 13: WEB DATABSE INTERFACING

2-13

Page/URL links

• The format for a link is as follows:

<A> HREF=“../menu.html”>Go back to Main Menu</A>

Opening Tag

File/URL to loadwhen link is selected.

Text that will be highlighted.

Closing tag

Page 14: WEB DATABSE INTERFACING

2-14

HTML Forms

• Creating forms consists of two major steps:– Create the form layout– Handle the data (scripts, mail, etc.)

• Forms are created using the <FORM> and </FORM> tags

• Do not nest <FORM> tags. It will not work.

Page 15: WEB DATABSE INTERFACING

2-15

HTML Forms - Cont’d

• Form Tag consists of two attributes:– Method - This can be either GET or POST. This

determines how form is handled by script.

– Action - Usually a pointer to a script. This can also be a pointer to a URL or instructions to mail a message.

• Format is as follows:– <FORM METHOD=POST

ACTION=“http://www.myserver.com/cgi-bin/script.cgi”>

– ……..

– </FORM>

Page 16: WEB DATABSE INTERFACING

2-16

Submitting a Form

<HTML><HEAD>

<TITLE> Sample Form</TITLE>

</HEAD><BODY>

<H2>What is your name?</H2>

<FORM METHOD=POST ACTION=“some action”>

<P>Enter your Name: <INPUT NAME=“theName”></P>

<P><INPUT TYPE=“SUBMIT” VALUE=“button name”></P>

</FORM>

</BODY></HTML>

Page 17: WEB DATABSE INTERFACING

2-17

Common Gateway Interfaces (CGI)

• CGI - (Common Gateway Interface) an interface that provides for running external programs to an HTML document.

• Gateway programs are often scripting languages like VBScript and Javascript.

• Programming language support can be Visual Basic, C++ or even Perl programs.

• Environment variables are used to send parameters to the script program.

Page 18: WEB DATABSE INTERFACING

2-18

CGI Implementations

• Two primary environment variables :– QUERY_STRING - anything following the

first question mark in the URL accessing the gateway.

– PATH_INFO - extra information embedded in the URL accessing the gateway.

Page 19: WEB DATABSE INTERFACING

2-19

CGI Implementations contd.

• HTTP request/response transactions use four steps:– Open a connection to the server– Issue the request to the server– Receive the results from the server– Close the connection.

• HTTP is a stateless system.

Page 20: WEB DATABSE INTERFACING

2-20

CGI Implementations contd.

• More complex methods can be setup for interaction with a server.

• State information can be stored and passed between the client and server (Allows DB to maintain history).

• State information can be appended to the results the client is passing the server.

• The CGI script could open a database and keep it open during the session.

• The CGI must track state, however.

• States can also be tracked with cookies.

Page 21: WEB DATABSE INTERFACING

2-21

VB CGI Example

HTTP Client

VB CGI

Includes CGI32.BAS

AccessDatabase

Page 22: WEB DATABSE INTERFACING

2-22

Database Interface Methods

• Below are just some other ways to access databases:– Cold Fusion– HTML forms interfacing to CGI.– ODBC– Database Markup Language (DBML)

Page 23: WEB DATABSE INTERFACING

2-23

CGI Database Scripting

• Last but not least, SQL:• SQL statements are embedded in the database

markup language.• <DBQUERY Name=“Employees”

Datasource=“EmployeeData” SQL=“SELECT * FROM dbEmployees WHERE EmpID = ‘#form.EID#’ “>

• This technique for generating a SQL statement for a database is proprietary to the vendor.

Page 24: WEB DATABSE INTERFACING

2-24

Web Server API’s

• Another way to access databases is with Server Applications Programming Interface (API) - native code proprietary to the Web server.

• Best performance possible with server.

• More difficult than CGI scripting, but much faster. Eliminates CGIs.

• Supports - multithreading, process synchronization,error handling, and programming at protocol level.

• Improperly written - can crash server.

Page 25: WEB DATABSE INTERFACING

2-25

ISAPI API

• ISAPI applications for Microsoft IIS server utilize DLL’s loading at the same address space as the Web server for better performance.

• Integrated with other Microsoft applications such as Back Office.

• GetExtensionVersion() - entry point for ISAPI - returns version number of the DLL.

• HttpExtensionProc() - is the entry point called for every client request.

Page 26: WEB DATABSE INTERFACING

2-26

ISAPI API contd.

• WriteClient() or ServerSupportFunction() must then be called for a response to the client from HttpExtensionProc().

• NSAPI - Netscapes server API cross-platform version works well as long as operating system calls are not made. NSAPI is more difficult.

• The FORM tag links to the ISAPI DLL - <FORM ACTION= “http://207.217.22.134/scripts/amulet.dll” METHOD=????>. This is similar to linking to a CGI.

Page 27: WEB DATABSE INTERFACING

2-27

Internet Database Connector

• Provides ODBC access for HTTP requests on an IIS server.

• Httpodbc.dll - the IDC ISAPI dll for ODBC database access.

• Two types of files control access:– .idc - contains necessary information to connect to he

database.

– .htx - HTML template for the file returned to the browser. ASP replaces this functionality.

Page 28: WEB DATABSE INTERFACING

2-28

Server Side Includes

• Allows small amounts of dynamic data to be inserted into an HTML document.

• Costs a fair amount of server resources.

• Tags are embedded into the HTML document and read by the server side implementation.

• A typical example of an SSI is a web counter.

Page 29: WEB DATABSE INTERFACING

2-29

Server Side Includes - Cont’d

• SSI requires high overhead (CPU and memory) because web server has to scan through entire HTML doc to find SSI commands.

• SSI was founded as freeware.

• <!--#SSIcommand tag1=“value1” tag2=“value2” -->

• SSI commands are ignored by non SSI capable servers because of the comment line. SSI aware servers will pick these up.

• This is a non-standard HTML document.

Page 30: WEB DATABSE INTERFACING

2-30

Server Side Include Commands

• SSI consists of six commands:– CONFIG

– INCLUDE

– ECHO

– FSIZE

– FLASTMOD

– EXEC

• A product called WebQuest has added some additional commands to SSI.

Page 31: WEB DATABSE INTERFACING

2-31

Java Database Connections

• Java Applets connect to a database using API’s provided by the vendor (native) or utilizing JDBC (a common API layer in Java).

• JDBC lets you hide the specifics of your database from the application.

• JDBC is platform independent.• DAO is available for use in the windows

environment to interface J++ with Access.

Page 32: WEB DATABSE INTERFACING

2-32

Active Server & ACTIVEX

• Active server scripting executes completely on the server and is based on VB scripting language.

• ACTIVEX controls execute on the server and return requested information in the HTML stream mixed with the regular HTML.

Page 33: WEB DATABSE INTERFACING

2-33

Active Server & ACTIVEX - Cont’d

• The following occurs when an ASP is first read by the server:– HTML and Client side scripting code found on page is

passed to the browser.

– If server-side script code is found, it runs on the server instead of being passed back to the browser.

• The browser does not know that page was created dynamically, it just displays the HTML.

Page 34: WEB DATABSE INTERFACING

2-34

ActiveX Data Objects

• ADO is an ACTIVEX Component module that utilizes the new OLE DB technology. Making remote objects look local.

• ADO is the data access component of ASP.• ADO allows you to independently create objects

where DAO and RDO require a hierarchy to be created for objects.

• ADO allows you to have build an object based interface.

Page 35: WEB DATABSE INTERFACING

2-35

Pop Quiz

• What components are needed for an HTML document?

• What is the difference between POST and GET forms?