Chapter 11: Active Server Pages

Download Report

Transcript Chapter 11: Active Server Pages

IS 4506
Interactive
Clients & Servers
 Overview

Fat Client versus Fat Server

Spectrum of Web content formats

Active Server Pages

Active Server Page elements

Use of the script tag
Client /Server Architecture
PCs
Middleware
Server
Web Client/Server Architecture
Client
Web Browser
INTERNET
INTRANET
HTTP
Server
Spectrum of Web Content Formats
Active
Personalization and Transaction Processing
Interactive Applications
Data-bound Applications
Dynamic HTML
Linked (Basic)
Content
Static
Active Server Pages

Dynamic content

Easy database connectivity

Scalable server-side solution

Integrated state and user management

Reusable software model
 Active Server Page Elements

ASP scripts

Objects

ASP built-in objects

Installable ASP objects

Installable ASP components

Component creation
ASP Scripts

Flexible server-side scripting

Exposes object model

Components accessed using properties and methods

Temperature conversion example

VBScript code
 Objects

ASP built-in objects

Installable ASP objects
ASP Built-in Objects

Server Object

Application Object

Session Object

Request Object

Response Object

ObjectContext Object
Component Creation

Created in any language

Components follow the COM standard

Accessed only by the server

Extend ActiveX server components
Use of the Script Tag

Script tag on Active Server Pages
<%
Code
%>
ASP Examples

Hello.htm

Hello.asp

Form.htm
Hello.htm
<HEAD>
<TITLE> Static Hello
</TITLE>
</HEAD>
<BODY>
<FONT SIZE = 7 >
Hello World!<BR>
</FONT>
</BODY>
</HTML>
Hello.asp
<%@ LANGUAGE = VBScript %>
<HEAD>
<TITLE>Active Hello Page
</TITLE>
</HEAD>
<BODY>
<% For I = 3 To 7 %>
<FONT SIZE=<%= I %>>
Hello World!<BR>
<% Next %>
</FONT>
</BODY>
</HTML>
Form.htm
<HTML>
<HEAD><TITLE>Order</TITLE></HEAD>
<H2>Sample Order Form</H2>
<P>Please provide the following info, then click Submit:</P>
<FORM METHOD="POST" ACTION="response.asp">
Title: <INPUT NAME=“title” SIZE=“5”><BR>
First Name: <INPUT NAME="fname" SIZE="48"><BR>
Last Name: <INPUT NAME="lname" SIZE="48">
<P><INPUT TYPE=SUBMIT><INPUT TYPE=RESET></P>
</FORM>
</BODY>
</HTML>
Response.asp
<%@ LANGUAGE = VBScript %>
Thank you,
<%
Title = Request.Form("title")
LastName = Request.Form("lname")
If Title = "mr" Then
%>
Mr. <%= LastName %>
<% ElseIf Title = "ms" Then %>
Ms. <%= LastName %>
<% Else %>
<%= Request.Form("fname") & " " & LastName %>
<% End If %>
for your order.<BR>
Response2.asp
<%@ LANGUAGE = VBScript %>
<%
Title = Request.Form("title")
LastName = Request.Form("lname")
FirstName = Request.Form("fname")
Response.Write "Thank you "
If Title = "mr" Then
Response.Write "Mr." & LastName
ElseIf Title = "ms" Then
Response.Write "Ms." & LastName
Else
Response.Write FirstName & " " & LastName
End If
Response.Write " for your order!!"
%>
mail.asp
<%@ LANGUAGE = VBScript %>
<%
Dim Message
Set message = CreateObject("CDONTS.NewMail")
message.send Request.Form("From"), Request.Form("To"),
Request.Form("Subject"), Request.Form("text")
Set message = Nothing
%>
The Following Email Has Been Sent:
<p>From: <%= Request.Form("From") %> </p>
<p>To: <%= Request.Form("To") %> </p>
<p>Subject: <%= Request.Form("Subject") %> </p>
<p>Text: <%= Request.Form("text") %> </p>
Lab 11: Active Server Pages
Review

Spectrum of Web content formats

Active Server Pages

Active Server Pages elements

Use of the script tag