350 likes | 432 Views
WEB DATABSE INTERFACING. Colorado Technical University IT420. Web Database Software. HTTP - (Hyper Text Transfer Protocol) an application level protocol supporting platform-independent communications.
E N D
WEB DATABSE INTERFACING Colorado Technical University IT420
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
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.
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.
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>
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>
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>
Incorrect Nesting • <HTML> • <HEAD> • <BODY> • </HEAD> • </BODY> • </HTML>
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.
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>
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/URL links • The format for a link is as follows: <A> HREF=“../menu.html”>Go back to Main Menu</A> File/URL to load when link is selected. Text that will be highlighted. Opening Tag Closing tag
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.
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>
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>
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.
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.
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.
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.
VB CGI Example HTTP Client VB CGI Includes CGI32.BAS Access Database
Database Interface Methods • Below are just some other ways to access databases: • Cold Fusion • HTML forms interfacing to CGI. • ODBC • Database Markup Language (DBML)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Pop Quiz • What components are needed for an HTML document? • What is the difference between POST and GET forms?