Internet
database access using Active Server Pages
Jelena Galic, B.Sc. EE
& CS (galic@EUnet.yu)
Miroslav Pesic, B.Sc. EE & CS (pesicm@EUnet.yu)
Essence of dynamic content on
the Web
Static Web content:
Dynamic Web content:
Pages (or their parts)
are generated on-the-fly, when Web client requests a page
from Web server.
Displayed content is
usually retrieved from databases stored on Web server.
Ideal for creation of
shopping sites and other electronic business related
content on the Internet.
Can be created using
ASP (Active Server Pages), CGI (Common Gateway
Interface), etc.
ASP vs. CGI
Essence of CGI (Common Gateway
Interface):
- Scripts or programs are stored on
server in cgi-bin directory.
- Scripts or programs use standard input
to retreive form or query string data sent by the client:
form data must be parsed in order to be useful.
- Scripts or programs use standard
output to produce HTML code: it is difficult and
time-consuming to control Web page appearance.
- Gateway programs are not integrated
into HTML files; in fact, they require an entirely
different design process than do HTML files.
- Supported by all Web servers.
Essence of ASP (Active Server
Pages):
ASP are made of server-side scripts
completely integrated with HTML files.
ASP documents have .asp extension.
Scripts are separated from HTML tags
and text using special delimiters (<% and %>).
Scripts can be placed anywhere inside or outside HTML
document.
Server-side script engine processes
all .asp documents requested by Web clients. HTML code
parts are sent to clients and script parts are
interpreted. Script output is sent together with HTML
code.
Standard support for VBScript (Visual
Basic Scripting Edition) and JavaScript. Other script
languages can be supported too with appropriate
server-side script engine.
ASP have support for client
certificates through Secure Sockets Layer (SSL) or
Private Communications Technology (PCT1).
Easy to create, with no manual
compiling or linking of programs required.
Great control of HTML output. It it
possible to use visual Web page editors and visually
insert scripts.
Object-oriented and extensible with
ActiveX server components.
ASP is Microsoft technology.
Requirements:
- Internet Information Server on
Windows NT Server.
- Microsoft Peer Web Services on
Windows NT Workstation.
- Personal Web Server on Windows
95/98 for less demanding users.
More on ASP
- An ASP script begins to run when a
browser requests an .asp file from your Web server. Your
Web server then calls ASP, which reads through the
requested file from top to bottom, executes any commands,
and sends an HTML page to the browser.
- A user who requests an ASP page cannot
see the scripts contained in the .asp file. Using a
browsers View Source command simply reveals the
HTML tags and text that have been returned to the browser
after the scripts have been executed.
- ASP has built-in objects with methods
for most frequently used operations:
- Sharing information among
users and page hit counting.
- Retrieving the values that the
client browser passed to the server during an
HTTP request.
- Sending output to the client.
- ASP has ActiveX server components for:
- Retrieving data from a
database (using ActiveX Data Abjects - ADO).
- Displaying advertisments on a
page.
- Determining browser
capabilities.
- Reading and writing to files.
- Managing page navigation.
An ASP example
Consider the following form.
<FORM ACTION = "/scripts/submit.asp" METHOD = "post">
<P>Your first name: <INPUT NAME = "firstname" SIZE = 48>
<P>What is your favorite ice cream flavor: <SELECT NAME = "flavor">
<OPTION>Vanilla
<OPTION>Strawberry
<OPTION>Chocolate
<OPTION>Rocky Road</SELECT>
<p><INPUT TYPE = SUBMIT>
</FORM>
From that form, the following request body
might be sent.
firstname=James&flavor=Rocky+Road
The following script can then be used.
Welcome, <%= Request.Form("firstname") %>.
Your favorite flavor is <%= Request.Form("flavor") %>.
The following output is the result.
Welcome, James. Your favorite flavor is Rocky Road.
If the following script is used:
The unparsed form data is: <%= Request.Form %>
The output would be:
The unparsed form data is: firstname=James&flavor=Rocky+Road