ASP.

Slides:



Advertisements
Similar presentations
Active Server Pages (ASP)
Advertisements

E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2.
Maintaining State Between the Client and Server Internet Programming Using VBScript and JavaScript 9.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1 Chapter 12 Working With Access 2000 on the Internet.
ASP Tutorial. What is ASP? ASP (Active Server Pages) is a Microsoft technology that enables you to make dynamic and interactive web pages. –ASP usually.
1 Today: Introduction to ASP- Part 1 Explain the client/server architecture Explain Web-based client/server applications Understand the essentials of Active.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
Introduction to Active Server Pages
Python and Web Programming
Basic Scripting in VBScript  VBScript must enclosed by  No HTML code is allowed inside a VBScript code block  Nested scripting block is not allowed.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Web Application Development Vijayan Sugumaran Decision and Information Sciences Oakland University.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Lecture Note 3: ASP Syntax.  ASP Syntax  ASP Syntax ASP Code is Browser-Independent. You cannot view the ASP source code by selecting "View source"
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
 2004 Tau Yenny, SI - Binus M0194 Web-based Programming Lanjut Session 1.
JavaScript, Fourth Edition
CIS 375—Web App Dev II ASP II. 2 ASP Session: Introduction The Session _______ is used to store information about, or change settings for a user session.
State Management. What is State management Why State management ViewState QueryString Cookies.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
ASP The Global.asa file Y.-H. Chen International College Ming-Chuan University Fall, 2004.
ASP Introduction Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Lecture Note 1: Getting Started With ASP.  Introduction to ASP  Introduction to ASP An ASP file can contain text, HTML tags and scripts. Scripts in.
Chapter 6 Server-side Programming: Java Servlets
Active Server Page - ASP in JavaScript 王金龍、陳彥錚 銘傳大學 資管系.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
Lecture Note 8: ASP Including Files and The Global.asa file.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
ASP Objects Active Server Pages (cont..) 1. 2 ASP : Objects ASP provides built-in objects for performing useful tasks that simplify web development.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP (COMPONENTS) Active Server Pages (cont..) 1. global.asa file The Global.asa file is an optional file that can contain declarations of objects, variables,
ASP.NET P AGE O BJECTS.  Each ASP.NET page inherits the PAGE object  The PAGE supplies 3 built in objects:  REQUEST: All information passed to the.
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Maintaining State in ASP. Problem - How do I maintain state information about the user  Several Methods –Cookies –Session variables –Hidden fields 
Application Object Controlling the Application Application Object Controlling the Application.
Active Server Pages Session - 3. Response Request ApplicationObjectContext Server Session Error ASP Objects.
ASP Syntax Y.-H. Chen International College Ming-Chuan University Fall, 2004.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
Server Object Server Object. The Server object represents a programmable interface to the HTTP service that provides a mechanism to administer and control.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
ASP Mr. Baha & Dr.Husam Osta  What is ASP?  Internet Information Services  How Does ASP Differ from HTML?  What can ASP do for you?  ASP Basic.
ASP – Web Programming Class  Ravi Anand. ASP – Active Server Pages What is ASP? - Microsoft Technology - Can Run using IIS/PWS/Others - Helps us create.
Lecture 6 Sara Almudauh ASP.NET Part 1 Development of Internet Application 1501CT - Sara Almudauh.
Active Server Pages (ASP)
Y.-H. Chen International College Ming-Chuan University Fall, 2004
ASP Explained By: Sarbjit Kaur.
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
Development of Internet Application 1501CT - Sara Almudauh
PHP / MySQL Introduction
ISC440: Web Programming 2 Server-side Scripting PHP 3
The Request & Response object
Client side & Server side scripting
Browser and Server Models
Chapter 2 Interacting with the Customer
PHP.
PHP an introduction.
Cookies A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer.
Presentation transcript:

ASP

Active Server Pages Microsoft Technology use to create and run dynamic, interactive Web server applications ASP is a program that runs inside IIS(Internet Information Service) PWS (Personal Web Server) is a smaller - but fully functional - version of IIS When a browser requests an ASP file, IIS passes the request to the ASP engine.

What is an ASP File? An ASP file is just the same as an HTML file An ASP file can contain text, HTML, XML, and Scripts Scripts in an ASP file are executed on the Server An ASP file has the file extension ".asp"

What you can do with ASP? Dynamically edit, change or add any content of a Web page Respond to user queries or data submitted from HTML forms Access any data or databases and return the results to a Browser Customize a Web page to make it more useful for individual Users The advantages of using ASP instead of CGI and Perl, are those of simplicity and speed Provide security since your ASP code can not be viewed from the browser

The Basic Syntax Rule An ASP file normally contains HTML tags, just like an HTML file. an ASP file can also contain server scripts, surrounded by the delimiters <% and %>. Server scripts are executed on the server, and can contain expressions, statements, Procedures or operators valid for the scripting language you prefer to use. the default scripting language is VBScript

Write Output to a Browser The response.write command is used to write output to a browser. Example <html> <body> <% response.write("Hello World!") %> // <%="Hello World!"%> </body> </html>

ASP Variables <%@ Language="Vbscript" %> <% Option Explicit %> VbScript is used, this is how you declare variable DIM varaibleName or Const variableName. <html> <body> <% dim h h="Hello World" response.write("Say: " & h) %> </body> </html>

Variable Example <% Dim name, email, age name=”John M” email=”you@you.com” age=35 response.write(“Your Name: “ & name & "<br>") response.write(“Your Email: “ & email & "<br">) response.Write(“Your age: “ & age) %>

ASP Arrays <% %> Dim Cars(3) cars(0)="Jeep Grand Cherokee" cars(1)="Jeep Wrangler" cars(2)="Jeep Liberty" cars(3)="Jeep Cherokee Briarwood" response.write(cars(0) & "<br>") response.write(cars(1) & "<br>") response.write(cars(2) & "<br>") response.write(cars(3) & "<br>") %>

Sub Procedures Function Procedures If Then—Else--End if Case Statement Loop Statements For…Loop – step counter Do…Loop (Until,While) While..Wend

#include Directive insert the content of one ASP file into another ASP file before the server executes it used to create functions, headers, footers, or elements that will be reused on multiple pages. <!--#include file ="somefilename"-->

ASP Objects

Request: To get information from the user Response: To send information to the user Server: To control the Internet Information Server Session: To store information about and change settings for the user's current Web-server session Application: To share application-level information and control settings for the lifetime of the application

Objects contains collections (bits of information that are accessed in the same way). Objects use methods to do some type of Procedure Properties to store any of the object's attributes Events

The Request object The Request object retrieves the values that the client browser passed to the server during an HTTP request. Syntax Request[.collection|property|method](variable)

Collections ClientCertificate Cookies Form QueryString ServerVariables Properties TotalBytes - total number of bytes the client is sending in the body of the request. Method BinaryRead

All variables can be accessed directly by calling Request(variable) without the collection name. In this case, the Web server searches the collections in the following order. QueryString Form Cookies ClientCertificate ServerVariables

Request.Form (“FirstName”) http://www.greetings.com/show.asp?CardID=128762173676 Request.QueryString (“FirstName”)

The Response object The Response object is used to send information to the user. Syntax Response.collection|property|method Collection Cookies- Specifies cookie values

Properties Buffer - Indicates whether page output is buffered. CacheControl - Determines whether proxy servers are able to cache the output generated by ASP. Charset - Appends the name of the character set to the content-type header. ContentType - Specifies the HTTP content type for the response. Expires- Specifies the length of time before a page cached on a browser expires. ExpiresAbsolute - Specifies the date and time on which a page cached on a browser expires.

Methods AddHeader Sets the HTML header name to value. AppendToLog Adds a string to the end of the Web server log entry for this request. BinaryWrite Writes the given information to the current HTTP output without any character-set conversion. Clear Erases any buffered HTML output. End Stops processing the .asp file and returns the current result. Flush Sends buffered output immediately. Redirect Sends a redirect message to the browser, causing it to attempt to connect to a different URL. Write Writes a variable to the current HTTP output as a string. This can be done by using the construct

<% dim numvisits response. cookies("NumVisits") <% dim numvisits response.cookies("NumVisits").Expires=date+365 numvisits=request.cookies("NumVisits") if numvisits="" then    response.cookies("NumVisits")=1    response.write("Welcome! This is the first time you are visiting this Web page.") else    response.cookies("NumVisits")=numvisits+1    response.write("You have visited this ")    response.write("Web page " & numvisits)    if numvisits=1 then      response.write " time before!"    else      response.write " times before!"    end if end if %>

Server.property|method Server object provides access to methods and properties on the server. Server.property|method Properties ScriptTimeout Methods CreateObject HTMLEncode Applies HTML encoding to the specified string. MapPath Maps the specified virtual path, either the absolute path on the current server or the path relative to the current page, into a physical path. URLEncode Applies URL encoding rules, including escape characters, to the string.

<% Dim DB Set DB = Server.CreateObject (“ADODB.Connection”) DB.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + “C:\Databases\Students.mdb”) Dim RS Set RS = Server.CreateObject (“ADODB.Recordset”) RS.Open “SELECT * FROM Students”, DB If RS.EOF And RS.BOF Then Response.Write “There are 0 records.” Else RS.MoveFirst While Not RS.EOF Response.Write RS.Fields (“FirstName”) Response.Write RS.Fields (“LastName”) Response.Write “<HR>” RS.MoveNext Wend End If %>

Session object Session.collection|property|method Collections Contents StaticObjects Properties CodePage - used for symbol mapping. LCID - locale identifier. SessionID Timeout

Methods Abandon This method destroys a Session object and releases its resources. Events Scripts for the following events are declared in the global.asa file. Session_OnEnd Session_OnStart

Application object store information that persists for the entire lifetime of an application Application.method Collections Contents - Contains all of the items of Application StaticObjects - objects added to the session with the <OBJECT> tag. Lock - prevents other clients from modifying Application object properties. Unlock - allows other clients to modify Application object

Events Application_OnEnd Application_OnStart

Global.asa Global.asa file is an optional file that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application. Application events Session events <object> declarations TypeLibrary declarations the #include directive

RESTRICTIONS This file can't display information Use Server and Application objects in the Application_OnStart and Application_OnEnd subroutines. In the Session_OnEnd subroutine, can use Server, Application, and Session objects. In the Session_OnStart subroutine you can use any built-in object.

<script language="vbscript" runat="server"> sub Application_OnStart 'some code end sub sub Application_OnEnd 'some code end sub sub Session_OnStart 'some code end sub sub Session_OnEnd 'some code end sub </script>

<object> Declarations It is possible to create objects with session or application scope in Global.asa by using the <object> tag. <object runat="server" scope="scope" id="id" {progid="progID"|classid="classID"}> .... </object> Parameter Description scope Sets the scope of the object (either Session or Application) id Specifies a unique id for the object ProgID An id associated with a class id. The format for ProgID is [Vendor.]Component[.Version] Either ProgID or ClassID must be specified. ClassID Specifies a unique id for a COM class object.

TypeLibrary Declarations A TypeLibrary is a container for the contents of a DLL file corresponding to a COM object. the constants of the COM object can be accessed errors can be better reported by the ASP code. <!--METADATA TYPE="TypeLib" file="filename" uuid="id" version="number" lcid="localeid" -->