Advanced Web Pages

(This material last modified

ASP, JSP, CFM, PHP

Common Gateway Interface (CGI) programs typically written in programming language like Perl, C, C++

Typically use .cgi extension regardless of programming language

Run on the server, with Web page delivered to browser

Some newer languages (Visual Basic, Java) being used for this purpose

.asp, .jsp, .cfm, .php extensions are for newer ways of handling programs run on server with results delivered to browser

ASP, JSP, CFM, PHP pages are basically HTML files with some embedded scripting (like JavaScript)

But, this scripting is run by server (unlike JavaScript)

CGI, ASP, JSP, CFM, PHP pages may not be cached -- can be real annoying if just going back to look at page looked at seconds ago

Active Server Pages (ASP)

Active Server Pages (ASP) introduced by Microsoft in 1996

ASP is HTML page that includes one or more scripts processed on a Microsoft Internet Information Server (IIS) Web server before the page is sent to the user

Typically, the script in the Web page at the server uses input received as the result of the user's request for the page to access data from a database

Builds or customizes the page before sending it to the client

Create an ASP file by including a script written in VBScript (subset of Visual Basic) or JScript in an HTML file

ASP is powerful at database handling because of database access technology ActiveX Data Objects (ADO). Easy to connect Website with database.

<%@ LANGUAGE="VBSCRIPT" %> <HTML> <HEAD> <TITLE>New Guest Book Entry</TITLE> </HEAD> <BODY BGCOLOR="WHITE"> <CENTER> Guest Book Entry <TABLE BORDER=0> <TR> <TD>Guest Name</TD> <TD><% Response.Write(guestname)%>/TD> </TR> <TR> <TD>Email</TD> <TD><% Response.Write(emailaddr)%></TD> </TR> <TR> <TD>Homepage URL</TD> <TD><% Response.Write(url)%>/TD> </TR> <TR> <TD>Message</TD> <TD><% Response.Write(message)%>/TD> </TR> </TABLE> </BODY> </HTML>

Java Server Pages (JSP)

Java Server Page (JSP) uses Java code that is executed by the Web server

Different from Java applets that run on the browser

<HTML> <HEAD> <TITLE>Welcome to Our Store</TITLE> </HEAD> <BODY> <H1>Welcome to Our Store</H1> Welcome, <!-- User name is "New User" for first-time visitors --> <% out.println (Utils.getUserNameFromCookie(request)); %> To access your account settings, click <A HREF="Account-Settings.html">here.</A> <P> ... Thanks for ordering <I><%= request.getParameter("title") %></I> <P> ... </BODY> </HTML>

Cold Fusion (CFM)

Cold Fusion developed by Allaire Corporation

Simple, powerful alternative to Perl and other CGI technologies

Cold Fusion is application that runs on Web server

Whenever Cold Fusion (.cfm) page requested, Cold Fusion Application Server executes script or program page contains

Cold Fusion is programming language

Cold Fusion makes interacting with database (Sybase, Oracle, MySQL, SQL, or Access) simple

Uses standard Structured Query Language (SQL) on Web pages

Web applications can easily retrieve, store, format, and present information dynamically

Tag Based -- CFML (Cold Fusion Markup Language) much like HTML

Integrates technologies -- CF tag <CFFORM> will automatically build all JavaScript code to verify required fields before form submits

Cold Fusion designed to build complex, high traffic web sites

search.html

<H2>Search Page</H2>

Search for an employee by Last Name
<P>

<FORM ACTION=results.cfm METHOD=GET>
<INPUT TYPE=TEXT NAME=lname> 
<INPUT TYPE=SUBMIT>
</FORM>

results.cfm

<!---Set Data Source Name--->
<CFSET DSN=EmpDbase>

<!---Get records from the database --->
<CFQUERY DATASOURCE='#DSN#' 
NAME='GetRecords'>
  select LastName, FirstName, Department
  from employee  
  where LastName like '%#lname#%' 
</CFQUERY>

<!---Output results--->
<H2>Search Results</H2>

<CFOUTPUT QUERY="GetRecords" 
STARTROW=1 MAXROWS=100>
#GetRecords.CurrentRow# #FirstName#
#LastName# #Department#
<BR>
</CFOUTPUT>

(Much of the above about Cold Fusion is adapted from ColdFusionHub.com and is used with permission.)

Personal Home Page (PHP)

PHP is a script language similar to JavaScript and Microsoft's VBScript

PHP used primarily on Linux Web servers

Earliest versions called "Personal Home Page Tools" -- now generally just referred to by initials PHP (like KFC)

PHP script (similar syntax to Perl or C) enclosed within PHP tags and embedded within Web page along with HTML

Before the page is sent to a user that has requested it, Web server calls PHP to interpret and perform the operations called for in the PHP script

An HTML page that includes a PHP script is typically given a file name suffix of ".php" ".php3," or ".phtml"

PHP's strength lies in its compatibility with many types of databases

PHP can talk across networks using IMAP, SNMP, NNTP, POP3, or HTTP

<HTML> <HEAD> <TITLE>Welcome to Our Store</TITLE> </HEAD> <BODY> <H1>Welcome to Our Store</H1> The information on this page was last changed <? $last_modified = filemtime("store.html"); print(date("m/j/y h:i", $last_modified)); ?> ... </BODY> </HTML>