ASP Explained By: Sarbjit Kaur.

Slides:



Advertisements
Similar presentations
Active Server Pages (ASP)
Advertisements

Other Web Application Development Technologies. PHP.
E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Maintaining State Between the Client and Server Internet Programming Using VBScript and JavaScript 9.
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
DT211/3 Internet Application Development Active Server Pages & IIS Web server.
Building Applications using ASP.NET and C# / Session 1 / 1 of 21 Session 1.
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 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
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
INTRODUCTION TO WEB DATABASE PROGRAMMING
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
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"
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.
 2004 Tau Yenny, SI - Binus M0194 Web-based Programming Lanjut Session 1.
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.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
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
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
ASP.NET in Definition: 1.ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites,
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.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
ASP Objects Active Server Pages (cont..) 1. 2 ASP : Objects ASP provides built-in objects for performing useful tasks that simplify web development.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
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. 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 
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.
Raina NEC Application Object Describes the methods, properties, and collections of the object that stores information related to the entire Web.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
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.
National College of Science & Information Technology.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Section 6.3 Server-side Scripting
WWW and HTTP King Fahd University of Petroleum & Minerals
Y.-H. Chen International College Ming-Chuan University Fall, 2004
Introduction to ASP By “FlyingBono” 2009_01 By FlyingBono 2009_01
Active Server Pages ASP.Net
PHP / MySQL Introduction
IS333D: MULTI-TIER APPLICATION DEVELOPMENT
ISC440: Web Programming 2 Server-side Scripting PHP 3
The Request & Response object
ASP.
Client side & Server side scripting
Web Development Using ASP .NET
Chapter 27 WWW and HTTP.
Browser and Server Models
PHP.
JavaScript.
Lesson 1 The Web.
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.
Web Application Development Using PHP
Presentation transcript:

ASP Explained By: Sarbjit Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh

CONTENT INTRODUCATION ASP OBJECTS WRITING SIMPLE ASP SCRIPT

INTRODUCATION ASP stands for Active Server Pages. Microsoft introduced Active Server Pages in December 1996, beginning with Version 3.0. Microsoft officially defines ASP as: “Active Server Pages is an open, compile-free application environment in which you can combine HTML, scripts, and reusable ActiveX server components to create dynamic and powerful Web-based business solutions. Active Server pages enables server side scripting for IIS with native support for both VBScript and Jscript.” (2). In other words, ASP is a Microsoft technology that enables you to create dynamic web sites with the help of server side script, such as VBScript and Jscript. ASP technology is supported on all Microsoft Web servers that are freely available. If you have Window NT 4.0 Server installed, you can download IIS (Internet Information Server) 3.0 or 4.0. If you are using Window 2000, IIS 5.0 comes with it as a free component. If you have Window 95/98, you can download Personal Web Server (PWS), which is a smaller version of IIS, from Window 95/98 CD. You can also download these products for free from Microsoft’s web site.

What is an ASP file An ASP file is quite like an HTML file. It contains text, HTML tags and scripts, which are executed on the server. The two widely used scripting languages for an ASP page are VBScript and JScript. VBScript is pretty much like Visual Basic, whereas Jscript is the Microsoft’s version of JavaScript. However, VBScript is the default scripting language for ASP (3). Besides these two scripting languages, you can use otherscripting language with ASP as long as you have an ActiveX scripting engine for thelanguage installed, such as PerlScript. 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"

The difference between an HTML file and an ASP file When a browser requests an HTML file, the server returns the file When a browser requests an ASP file, IIS passes the request to the ASP engine. The ASP engine reads the ASP file, line by line, and executes the scripts in the file. Finally, the ASP file is returned to the browser as plain HTML HTML tags begins with lesser than (<) and greater than (>) brackets, whereas ASP script typically starts with <% and ends with %>. To write an ASP script, you don’t need any additional software because it can be written with any HTML editor, such as Notepad.

How does it work? HTML process ASP process As you have learned, scripts in an ASP file are server-side scripts, which means that thescripts are processed on the server and then the result of the scripts will be converted to HTML before sending to the web browser. To illustrate, let’s take a look at this table to compare the process of retrieving an HTML page and an ASP pag. HTML process ASP process A user requests a web page in the web browse. The browser finds the appropriate web server, and asks for the required page. The web server locates the required page and sends it back to the browser as HTML text. The browser finds the appropriate web server (like IIS or PWS), and asks for the required page. The web server locates the required page, and parses out the ASP code within the ASP script delimiters (<%…%>), produces a standard HTML page. The server sends that HTML page back to the browser, so the user cannot see ASP code

What can ASP do for you? 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 ASP code cannot be viewed from the browser Clever ASP programming can minimize the network traffic.

ASP OBJECTS Following are the six built in ASP objects : Response Request Application Session Server Object context ASPError

Response object Collections: The ASP Response object is used to send output to the user from the server. Its collections, properties, and methods are described below: Collections: Collection Description Cookies Sets a cookie value. If the cookie does not exist, it will be created, and take the value that is specified

Properties Property Description Buffer Specifies whether to buffer the page output or not CacheControl Sets whether a proxy server can cache the output generated by ASP or not Charset Appends the name of a character-set to the content-type header in the Response object ContentType Sets the HTTP content type for the Response object Expires Sets how long (in minutes) a page will be cached on a browser before it expires ExpiresAbsolute Sets a date and time when a page cached on a browser will expire IsClientConnected Indicates if the client has disconnected from the server Pics Appends a value to the PICS label response header Status Specifies the value of the status line returned by the server

Methods Method Description AddHeader Adds a new HTTP header and a value to the HTTP response AppendToLog Adds a string to the end of the server log entry BinaryWrite Writes data directly to the output without any character conversion Clear Clears any buffered HTML output End Stops processing a script, and returns the current result Flush Sends buffered HTML output immediately Redirect Redirects the user to a different URL Write Writes a specified string to the output

Request When a browser asks for a page from a server, it is called a request. The Request object is used to get information from a visitor. Its collections, properties, and methods are described below: Collections: Collection Description ClientCertificate Contains all the field values stored in the client certificate Cookies Contains all the cookie values sent in a HTTP request Form Contains all the form (input) values from a form that uses the post method QueryString Contains all the variable values in a HTTP query string ServerVariables Contains all the server variable values

Properties and methods Property Description TotalBytes Returns the total number of bytes the client sent in the body of the request Method Description BinaryRead Retrieves the data sent to the server from the client as part of a post request and stores it in a safe array

Application An application on the Web may consists of several ASP files that work together to perform some purpose. The Application object is used to tie these files together. The Application object is used to store and access variables from any page, just like the Session object. The difference is that ALL users share ONE Application object (with Sessions there is ONE Session object for EACH user). The Application object holds information that will be used by many pages in the application (like database connection information). The information can be accessed from any page. The information can also be changed in one place, and the changes will automatically be reflected on all pages. The Application object's collections, methods, and events are described below: Collections: Collection Description Contents Contains all the items appended to the application through a script command StaticObjects Contains all the objects appended to the application with the HTML <object> tag

Methods and Events Method Description Contents.Remove Deletes an item from the Contents collection Contents.RemoveAll() Deletes all items from the Contents collection Lock Prevents other users from modifying the variables in the Application object Unlock Enables other users to modify the variables in the Application object (after it has been locked using the Lock method) Event Description Application_OnEnd Occurs when all user sessions are over, and the application ends Application_OnStart Occurs before the first new session is created (when the Application object is first referenced)

Session When you are working with an application on your computer, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you open the application and when you close it. However, on the internet there is one problem: the web server does not know who you are and what you do, because the HTTP address doesn't maintain state. ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the user's computer and it contains information that identifies the user. This interface is called the Session object. The Session object stores information about, or change settings for a user session. Variables stored in a Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new Session object for each new user, and destroys the Session object when the session expires.

Collections and Properties Description Contents Contains all the items appended to the session through a script command StaticObjects Contains all the objects appended to the session with the HTML <object> tag Property Description CodePage Specifies the character set that will be used when displaying dynamic content LCID Sets or returns an integer that specifies a location or region. Contents like date, time, and currency will be displayed according to that location or region SessionID Returns a unique id for each user. The unique id is generated by the server Timeout Sets or returns the timeout period (in minutes) for the Session object in this application

Methods and Events Method Description Abandon Destroys a user session Contents.Remove Deletes an item from the Contents collection Contents.RemoveAll() Deletes all items from the Contents collection Event Description Session_OnEnd Occurs when a session ends Session_OnStart Occurs when a session starts

Server The ASP Server object is used to access properties and methods on the server. Its properties and methods are described below: Properties : Methods: Property Description ScriptTimeout Sets or returns the maximum number of seconds a script can run before it is terminated Method Description CreateObject Creates an instance of an object Execute Executes an ASP file from inside another ASP file GetLastError() Returns an ASPError object that describes the error condition that occurred HTMLEncode Applies HTML encoding to a specified string MapPath Maps a specified path to a physical path Transfer Sends (transfers) all the information created in one ASP file to a second ASP file URLEncode Applies URL encoding rules to a specified string

Object context The ObjectContext object is used to commit or abort transactions. For an .asp page to commit transaction, @TRANSACTION directive should be present in the script. Methods and Events: Methods Description SetAbort Aborts the transaction initiated by the ASP script. SetComplete Declares that there is no reason for the transaction not to complete. So if all the components taking part in the transaction also call SetComplete method then the transaction will complete Events Description OnTransactionAbort This event occurs when the transaction is aborted. OnTransactionCommit This event occurs when the transactional script's transaction is committed.

ASPError The ASPError object was implemented in ASP 3.0 and is available in IIS5 and later. The ASPError object is used to display detailed information of any error that occurs in scripts in an ASP page. The ASPError object's properties are described below (all properties are read-only): Properties: Property Description ASPCode Returns an error code generated by IIS ASPDescription Returns a detailed description of the error (if the error is ASP-related) Category Returns the source of the error (was the error generated by ASP? By a scripting language? By an object?) Column Returns the column position within the file that generated the error Returns a short description of the error File Returns the name of the ASP file that generated the error Line Returns the line number where the error was detected Number Returns the standard COM error code for the error Source Returns the actual source code of the line where the error occurred

WRITING SIMPLE ASP SCRIPT An ASP file normally contains HTML tags, just like an HTML file. However, an ASP file can also contain server scripts, surrounded by the delimiters <% and %>. Server scripts are executed on the server, and can contain any expressions, statements, procedures, or operators valid for the scripting language you prefer to use. The response.write Command The response.write command is used to write output to a browser. The following example sends the text "Hello World" to the browser: Example: <html> <body> <% response.write("Hello World!") %> </body> </html>

Example There is also a shorthand method for the response.write command. The following example also sends the text "Hello World" to the browser: <html> <body> <% ="Hello World!" %> </body> </html>