Lecture Note 8: ASP Including Files and The Global.asa file.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

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.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Building Applications using ASP.NET and C# / Session 1 / 1 of 21 Session 1.
1 Chapter 12 Working With Access 2000 on the Internet.
Web Page Behavior IS 373—Web Standards Todd Will.
Server-Side Scripting with ASP.Net ISYS 546. ASP.NET ASP.NET is a server-side technology for creating dynamic web pages. ASP.NET allows you to use a selection.
Client State Management & Application Security  Client State Management  Concept  ASP Examples  Application Security  Database Based Approach 
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Server- Side technologies Client-side vs. Server-side scripts PHP basic ASP.NET basic ColdFusion.
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"
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
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.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
Session 10: Managing State. Overview State Management Types of State Management Server-Side State Management Client-Side State Management The Global.asax.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
ASP The Global.asa file Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Department of Computer Science 1 Web/Database Integration with Active Server Pages 17 May 2000 Seree Chinodom Computer Science Department.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
Swiss Federal Institute of Technology 1 Active Server Pages (ASP) n The simplest example: Additionally ASP may contain code (scripts, ActiveX controls)
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
JavaScript Syntax, how to use it in a HTML document
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
8 th Semester, Batch 2008 Department Of Computer Science SSUET.
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.
Client-side & Server-side Scripting ©Richard L. Goldman August 5, 2003 Requires PowerPoint 2002 or later for full functionality.
Lecture Note 7: Sessions and Applications Object.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
1 Web/Database Integration with Active Server Pages 15th/16th October 1998 Nick Gould Faculty of Economic and Social.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
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,
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
 A PHP script can be placed anywhere in the document.  A PHP script starts with  The default file extension for PHP files is ".php".  A PHP file normally.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
Maintaining State in ASP. Problem - How do I maintain state information about the user  Several Methods –Cookies –Session variables –Hidden fields 
ASP.NET – Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework.
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.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
Raina NEC Application Object Describes the methods, properties, and collections of the object that stores information related to the entire Web.
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
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 – Web Programming Class  Ravi Anand. ASP – Active Server Pages What is ASP? - Microsoft Technology - Can Run using IIS/PWS/Others - Helps us create.
Introduction to Dynamic Web Programming
Y.-H. Chen International College Ming-Chuan University Fall, 2004
ASP Explained By: Sarbjit Kaur.
Section 17.1 Section 17.2 Add an audio file using HTML
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript Introduction
ASP.
Tutorial 10: Programming with javascript
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:

Lecture Note 8: ASP Including Files and The Global.asa file

 ASP Including Files  ASP Including Files The #include Directive With the #include directive, you can insert the content of one ASP file into another ASP file before the server executes it. The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages.

 ASP Including Files  ASP Including Files How to Use the #include Directive Example File name: "includetest.asp": Include Directive Test: The time is:

 ASP Including Files  ASP Including Files How to Use the #include Directive Here is the "doctest.inc" file: "Hello!! This is a test for Include Directive.“ Here is the "time.inc" file: If you look at the source code in a browser, it will look something like this: Include Directive Test: " Hello!! This is a test for Include Directive." The time is: 11:22:33 PM

 ASP Including Files  ASP Including Files Syntax for Including Files To include a file in an ASP page, place the #include directive inside comment tags: or The Virtual Keyword Use the virtual keyword to indicate a path beginning with a virtual directory. If a file named "header.inc" resides in a virtual directory named /html, the following line would insert the contents of "header.inc":

 ASP Including Files  ASP Including Files The File Keyword Use the file keyword to indicate a relative path. A relative path begins with the directory that contains the including file. If you have a file in the html directory, and the file "header.inc" resides in html\headers, the following line would insert "header.inc" in your file: The path to the included file (headers\header.inc) is relative to the including file. If the file containing this #include statement is not in the html directory, the statement will not work. To include a file from a higher-level directory, you can use the file keyword with the syntax (..\) Important: Included files are processed and inserted before the scripts are executed

 ASP Including Files  ASP Including Files The following scripts will not work : "--> Next %> But this script will work:

The Global.asa file The Global.asa file The Global.asa file The 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. All valid browser scripts (JavaScript, VBScript, JScript, PerlScript, etc.) can be used within Global.asa. The Global.asa file can contain only the following: Application events Session events declarations TypeLibrary declarations the #include directive Note: The Global.asa file must be stored in the root directory of the ASP application, and each application can only have one Global.asa file.

The Global.asa file The Global.asa file Session_OnEnd – This event occurs EVERY time a user ends a session. A user ends a session after a page has not been requested by the user for a specified time (by default this is 20 minutes). Application_OnEnd – This event occurs after the LAST user has ended the session. Typically, this event occurs when a Web server stops. This procedure is used to clean up settings after the Application stops, like delete records or write information to text files.

The Global.asa file The Global.asa file A Global.asa file could look something like this: sub Application_OnStart '‘……''some code end sub sub Application_OnEnd “……”some code end subsub Session_OnStart '‘…….''some code end subsub Session_OnEnd '‘…….''some code end sub

The Global.asa file The Global.asa file Restrictions Restrictions on what you can include in the Global.asa file: You can not display text that is written in the Global.asa file. This file can't display information You can only use Server and Application objects in the Application_OnStart and Application_OnEnd subroutines. In the Session_OnEnd subroutine, you can use Server, Application, and Session objects. In the Session_OnStart subroutine you can use any built-in object

The Global.asa file The Global.asa file How to use the Subroutines Global.asa is often used to initialize variables. Global.asa can also be used to control page access. You can include functions in the Global.asa file. The example below shows how to detect the exact time a visitor first arrives on a Web site. The time is stored in a Session variable named "started", and the value of the "started" variable can be accessed from any ASP page in the application: sub Session_OnStart Session("started")=now() end sub

The Global.asa file The Global.asa file The example below shows how to redirect every new visitor to another page, in this case to a page called "newpage.asp": sub Session_OnStart Response.Redirect("newpage.asp") end sub

The Global.asa file The Global.asa file Global.asa Example In this example we will create a Global.asa file that counts the number of current visitors. The Application_OnStart sets the Application variable "visitors" to 0 when the server starts The Session_OnStart subroutine adds one to the variable "visitors" every time a new visitor arrives The Session_OnEnd subroutine subtracts one from "visitors" each time this subroutine is triggered

The Global.asa file The Global.asa file Global.asa Example The Global.asa file: Sub Application_OnStart Application("visitors")=0 End Sub Sub Session_OnStart Application.Lock Application("visitors")=Application("visitors")+1 Application.UnLock End Sub Sub Session_OnEnd Application.Lock Application("visitors")=Application("visitors")-1 Application.UnLock End Sub

The Global.asa file The Global.asa file Global.asa Example To display the number of current visitors in an ASP file: There are online now!