Title: BMIS 289 Spring 2001
1BMIS 289 Spring 2001
- ASP Introduction
- Class 1
- January 22, 2001
2What is ASP?
- Active Server Pages
- Dynamic web pages
- Processing a web page before it is presented to
the user - Static vs. Dynamic
- Static changes manually made to page.
- Dynamic page changes based on multiple and
varied criteria. - Server-side vs. Client-side
- Server-side Processes occur on the agent that
is acting as the server. (e.g., web server) - Client-side process occurs on the agent acting
as the client (e.g., PC)
3ASP as an Application Framework
- ASP allows normally static web pages to be used
as part of an overall application. - Rich programming language (VBScript)
- Data access
- Mutli-tiered, scaled, and object-oriented design
4Software Development Lifecycle (SDLC)
- Plan
- What are the goals of the application?
- Design
- Is ASP an appropriate tool?
- Construct
- Program and debug
- Implement
- Beta testing, release
- Maintenance
- Never ends
5What is ASP used for?
- E-Commerce (B2C)
- Amazon.com, etc
- B2B (e-biz)
- Business-to-Business
- Intranets/Extranets
- Internal HR systems, sharing data between vendors
and suppliers. - Thin Clients
- Cheap network PCs, powerful central servers
6The Basic ASP Model
- Programmer writes ASP code
- Code placed on server (ASP pages)
- Client makes request for page on server
- - any inputs are entered at this time
- Web server receives request (and input values),
processes ASP code. - Results returned to user as an HTML stream
- Client renders HTML
7HTML Refresh
- HTML Hypertext Markup Language
- HTML is not a programming language
- HTML cannot add numbers for example.
- HTML is a presentation language.
- It is a way of describing how data is presented.
- The power of ASP is in its ability to manipulate
HTML on the fly.
8HTML Refresh - Tags
- HTML uses tags to indicate where specific
formatting should be applied. - Example
- ltbgtThis sentence is boldlt/bgt
- ltbgt begin bold tag
- This sentence is bold is the literal that is
affected by the bold tag. - lt/bgt end bold tag
9HTML Refresh Tag Properties
- HTML tags can have properties which provide more
description about the effect a particular tag
will have on the literal it surrounds. - Example
- ltfont faceArialgtI am in Arial fontlt/fontgt
- face is the property of this font tag, and
Arial is its value. - All words in between that font tag will be
rendered in the Arial font (if its available on
the clients machine).
10HTML Refresh Basic HTML Page
lthtmlgtltheadgt lttitlegtPage Titlelt/titlegt lt/headgt lt
bodygt lt/bodygtlt/htmlgt
11HTML Refresh Try This Yourself
- Type this HTML into an empty document in Notepad,
save as page.htm, and open with web browser.
lthtmlgtltheadgt lttitlegtMy Pagelt/titlegtlt/headgtltbod
ygtHello!ltbrgt lta hrefhttp//www.gonzaga.edugtGo
nzaga!lt/agtlt/bodygtlt/htmlgt
12HTML Refresh Common Tags
- Links
- lta hrefhttp//www.gonzaga.edugtGUlt/agt
- lta hrefhome.htmgtGo Homelt/agt
- home.htm should be located in same directory as
the HTML file with this link in it. - lt a hrefdocs/doc1.htmgtdocumen1lt/agt
- doc1.htm is located in a folder called docs
which is a child folder of the folder in which
the HTML file with this link resides in.
13HTML Refresh Common Tags Cont.
- Line break
- Line1ltbrgtLine2
- This renders asLine1Line2
- Paragraph
- ltpgtLine 1 in paragraph 1lt/pgtltpgtLine 2 in
paragraph 2lt/pgt - This renders asLine 1 in paragraph 1Line 2 in
paragraph 2
14HTML Refresh Common Tags Cont.
- Image
- ltimg srchello.gifgt
- Font
- ltfont facearial size2gttextlt/fontgt
- Italics, bold, underline
- ltIgtitalicslt/Igt, ltbgtboldlt/bgt, ltugtunderlinelt/ugt
- Horizontal rule
- lthrgt
15HTML Refresh - Forms
- Forms are used to receive input from users in a
web browser. - They follow this basic format
ltformgt Form field tags lt/formgt
16HTML Refresh Form Field Tags
- Text box
- ltinput typetext nameinputboxgt
- Drop down menu
- ltselect namecitiesgt ltoptiongtSpokanelt/optiongt lto
ptiongtSeattlelt/optiongtlt/selectgt - Submit button
- ltinput typesubmit valueClick Heregt
17HTML Refresh Form Example
ASP page this forms data will be sent to
ltform nameInputForm methodpost
actionprocess.aspgt Name ltinput typeText
nameUserNamegtltbrgt City ltselect
nameCitygt ltoptiongtSpokanelt/optiongt ltoptiongtSe
attlelt/optiongt ltoptiongtPortlandlt/optiongt ltopti
ongtBoiselt/optiongt lt/selectgtltbrgt ltinput
typesubmit value"click here"gt lt/formgt
18Web Servers
- A web server is a piece of software that serves
up web pages and other information over the
Internet. - The web server also acts as the processing engine
for ASP. It interprets the ASP code and executes
its instructions. - This is different from compiled code, which is
actual machine code, and is more like Java.
19Web Servers Cont.
- IIS
- Internet Information Server
- IIS is Microsofts web server software that is
used on Windows NT Server and Windows 2000
server. - PWS
- Personal Web Server
- A light version of IIS that runs on Windows
98/95, Windows NT4 Workstation, and Windows 2000
Professional
20Using PWS in the GU Lab
- Starting Personal Web Server (PWS) in the Jepson
Labs - Select Start/Settings/Control Panel
- Double-click the Services icon in the Control
Panel window - Select World Wide Web Publishing Service in the
Service list. - Click Start
- Personal Web Server will then start. You may
receive an error message when starting this
service, but ignore it. - When PWS starts a small icon will appear in the
task bar . Double-clicking this icon will launch
the Personal Web Manager. - Be sure to stop the World Wide Web Publishing
Service when youre done
21C\Inetpub\wwwroot
- By default, a web sites files should be located
off the root directory - C\inetpub\wwwroot
- Example
- Place an HTML file called sample.htm in the
wwwroot folder. - Open your web browser and enter the url
http//localhost/sample.htm
22ASP Code
- Typically ASP code is embedded within an HTML
page. - The web server processes the ASP code before
processing any HTML code. - Like HTML, ASP code is indicated by using tags
- lt ASP code goes here gt
23A Simple Block of ASP Code
ltDim MyNameMyName ColinResponse.Write
MyNamegt
- Dim MyName
- Create a variable called MyName
- MyName Colin
- Place the value Colin into the variable
MyName - Response.Write MyName
- Output the value of the variable MyName
24Putting ASP code together with HTML
lthtmlgtltheadgt lttitlegtTestlt/titlegtlt/headgtltbodygt
Hello, my name is... ltDim MyNameMyName
"ColinResponse.Write MyNamegt lt/bodygtlt/htmlgt
25Input and Output with ASP
- Recall that we use HTML forms to gather input
from a user. - Form is written in HTML
- User enters values into form fields (e.g., text
boxes) - ASP page retrieves values from those fields and
processes them. - The value of a particular form is retrieved using
the Request.Form method - Request.Form(City)
- This method (function) returns the value from the
form field called City.
26Input and Output with ASP Example
lthtmlgt ltheadgt lttitlegtInputlt/titlegt lt/headgt ltbodygt
ltform actionprocess.asp methodpostgt Enter
your name ltinput typetext nameNamegt ltinput
typesubmit value"submit"gt lt/formgt lt/bodygt lt/htm
lgt
27Input and Output with ASP Example Cont.
lthtmlgt ltheadgt lttitlegtOutputlt/titlegt lt/headgt ltbody
gt Hi, your name is lt Dim UserName UserName
Request.Form("UserName") Response.Write
UserName gt lt/bodygt lt/htmlgt
28ASP Comments
- ASP comments are indicated by the single-quote
character - Example
lt output the variable Response.Write
MyVariable gt
- All text after the single-quote, on the same
line, is ignored by the ASP processor.
29Program 1
- Data Conversion
- When you retrieve numeric values from HTML form
fields they need to be converted to numbers in
order to perform mathematical operations on them
In ten years you will be lt Dim Age Age
Request.Form("Age") Age Cint(Age) use Cdbl()
to allow for decimals Response.Write Age 10 gt
30Program 1
- Double data type conversion
- Cdbl(Request.Form(Price))
- For decimal accuracy
- Output shortcut
- lt UserName gt
- Current date and time
- Processed at lt Now gt
- Multiplication
- MyVar 10 10
31End