cuadernillo asp
TRANSCRIPT
-
8/3/2019 Cuadernillo ASP
1/35
An ASP file can contain text, HTML tags and scripts.
Scripts in an ASP file are executed on the server.
What you should already know
Before you continue you should have some basic understanding of thefollowing:
HTML / XHTML
A scripting language like JavaScript or VBScript
If you want to study these subjects first, find the tutorials on ourHome page.
What is ASP?
ASP stands forActive ServerPages
ASP is a Microsoft Technology
ASP is a program that runs inside IIS
IIS stands forInternet Information Services
IIS comes as a free component with Windows 2000
IIS is also a part of the Windows NT 4.0 Option Pack
The Option Pack can be downloaded from Microsoft
PWS is a smaller - but fully functional - version of IIS
PWS can be found on yourWindows 95/98 CD
ASP Compatibility
To run IIS you must have Windows NT 4.0 or later To run PWS you must have Windows 95 or later
ChiliASP is a technology that runs ASP without Windows OS
InstantASP is another technology that runs ASP without Windows
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"
How Does ASP Differ from HTML?
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 ASPengine. The ASP engine reads the ASP file, line by line, and executes thescripts in the file. Finally, the ASP file is returned to the browser as plainHTML
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 simplicityand speed
Provide security - since ASP code cannot be viewed from the browser Clever ASP programming can minimize the network traffic
Note: Because ASP scripts are executed on the server, the browser that displays theASP file does not need to support scripting at all!
Run ASP on Your Own PC
You can run ASP on your own PC.
Your Windows PC as a Web Server
Your own PC can act as a web server if you install IIS or PWS IIS or PWS turns your computer into a web server
Microsoft IIS and PWS are free web server components
IIS - Internet Information Server
IIS is a set of Internet-based services for servers created by Microsoft for use withMicrosoft Windows.IIS comes with Windows 2000, XP, and Vista. It is also available for Windows NT.IIS is easy to install and ideal for developing and testing web applications.
PWS - Personal Web Server
1
http://www.w3schools.com/default.asphttp://www.w3schools.com/default.asp -
8/3/2019 Cuadernillo ASP
2/35
PWS is for older Windows system like Windows 95, 98, and NT.PWS is easy to install and can be used for developing and testing webapplications including ASP.We don't recommend running PWS for anything else than training. It is outdatedand has security issues.
Windows Web Server Versions
Windows Vista Business, Enterprise and Ultimate come with IIS 7
Windows Vista Home Premium comes with IIS 7
Windows Vista Home Edition does not support PWS or IIS
Windows XP Professional comes with IIS 5.1
Windows XP Home Edition does not support IIS or PWS
Windows 2000 Professional comes with IIS 5.0
Windows NT Professional comes with IIS 3 and also supports IIS 4
Windows NT Workstation supports PWS and IIS 3
Windows ME does not support PWS or IIS
Windows 98 comes with PWS
Windows 95 supports PWS
How to Install IIS on Windows Vista
Follow these steps to install IIS on Windows Vista:
1. Open the Control Panel from the Start menu2. Double-click Programs and Features3. Click "Turn Windows features on or off" (a link to the left)4. Select the check box for Internet Information Services (IIS), and click
OK
After you have installed IIS, make sure you install all patches for bugs andsecurity problems. (Run Windows Update).
How to Install IIS on Windows XP and Windows 2000
Follow these steps to install IIS on Windows XP and Windows 2000:
1. On the Start menu, click Settings and select Control Panel2. Double-click Add or Remove Programs3. Click Add/Remove Windows Components4. Click Internet Information Services (IIS)5. Click Details
6. Select the check box for World Wide Web Service, and click OK
7. In Windows Component selection, click Next to install IIS
After you have installed IIS, make sure you install all patches for bugs and securityproblems. (Run Windows Update).
Test Your Web
After you have installed IIS or PWS follow these steps:
1. Look for a new folder called Inetpub on your hard drive2. Open the Inetpub folder, and find a folder named wwwroot3. Create a new folder, like "MyWeb", under wwwroot4. Write some ASP code and save the file as "test1.asp" in the new folder5. Make sure your Web server is running (see below)6. Open your browser and type "http://localhost/MyWeb/test1.asp", to view your
first web page
Note: Look for the IIS (or PWS) symbol in your start menu or task bar. The programhas functions for starting and stopping the web server, disable and enable ASP, and
much more.
How to install PWS on Windows 95, 98, and Windows NT
For Windows 98: Open the Add-ons folder on your Windows CD, find the PWS folderand run setup.exe to install PWS.For Windows 95 or Windows NT: Download "Windows NT 4.0 Option Pack" fromMicrosoft, and install PWS.Test your web as described above.
How to install IIS on Windows Server 2003
1. When you start the Windows Server 2003, you should see the Manage YourServer wizard
2. If the wizard is not displayed, go to Administrative Tools, and selectManage Your Server
3. In the wizard, clickAdd or Remove a Role, click Next4. Select Custom Configuration, click Next5. Select Application Server role, click Next6. Select Enable ASP.NET, click Next7. Now, the wizard may ask for the Server 2003 CD. Insert the CD and let it run
until it is finished, then click the Finish button8. The wizard should now show the Application Server role installed
2
-
8/3/2019 Cuadernillo ASP
3/35
9. Click on Manage This Application Server to bring up theApplication Server Management Console (MMC)
10. Expand the Internet Information Services (IIS) Manager, thenexpand your server, and then the Web Sites folder
11. You should see the Default Web Site, and it should not say (Stopped)12. IIS is running!
13. In the Internet Information Services (IIS) Manager click on the
Web Service Extensions folder14. Here you will see that Active Server Pages are Prohibited (this is the
default configuration of IIS 6)
15. Highlight Active Server Pages and click the Allow button16. ASP is now active!
ASP Basic Syntax Rules
In our ASP tutorial, every example shows the hidden ASP source code. This willmake it easier for you to understand how it works.
Write Output to a Browser
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 .Server scripts are executed on the server,and can contain any expressions,statements, procedures, or operators valid for the scripting language you preferto 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
There is also a shorthand method for the response.write command. The followingexample also sends the text "Hello World" to the browser:
Example
Using VBScript in ASP
You can use several scripting languages in ASP. However, the default scriptinglanguage is VBScript:The example above writes "Hello World!" into the body of the document.
Using JavaScript in ASP
To set JavaScript as the default scripting language for a particular page you must inserta language specification at the top of the page:Note: JavaScript is case sensitive! You will have to write your ASP code withuppercase letters and lowercase letters when the language requires it.
3
-
8/3/2019 Cuadernillo ASP
4/35
Other Scripting Languages
ASP is shipped with VBScript and JScript (Microsoft's implementation ofJavaScript). If you want to script in another language, like PERL, REXX, orPython, you will have to install script engines for them.
ASP Variables
Lifetime of VariablesA variable declared outside a procedure can be accessed and changed by anyscript in the ASP file.A variable declared inside a procedure is created and destroyed every time theprocedure is executed. No scripts outside the procedure can access or change thevariable.To declare variables accessible to more than one ASP file, declare them assession variables or application variables.
Session Variables
Session variables are used to store information about ONE single user, and areavailable to all pages in one application. Typically information stored in sessionvariables are name, id, and preferences.
Application Variables
Application variables are also available to all pages in one application.Application variables are used to store information about ALL users in onespecific application.ASP Procedures
In ASP you can call a JavaScript procedure from a VBScript and vice versa.
Procedures
The ASP source code can contain procedures and functions:
Example
Result:
Insert the line above the tag to write theprocedure/function in another scripting language:
Example
Result:
Differences Between VBScript and JavaScript
When calling a VBScript or a JavaScript procedure from an ASP file written inVBScript, you can use the "call" keyword followed by the procedure name. If aprocedure requires parameters, the parameter list must be enclosed in parentheses whenusing the "call" keyword. If you omit the "call" keyword, the parameter list must not beenclosed in parentheses. If the procedure has no parameters, the parentheses are
optional.4
-
8/3/2019 Cuadernillo ASP
5/35
When calling a JavaScript or a VBScript procedure from an ASP file written inJavaScript, always use parentheses after the procedure name.
ASP Forms and User Input
The Request.QueryString and Request.Form commands are used to retrieve userinput from forms.
User Input
The Request object can be used to retrieve user information from forms.
Example HTML form
First Name:
Last Name:
User input can be retrieved with the Request.QueryString or Request.Formcommand.
Request.QueryString
The Request.QueryString command is used to collect values in a form withmethod="get".Information sent from a form with the GET method is visible to everyone (it willbe displayed in the browser's address bar) and has limits on the amount ofinformation to send.If a user typed "Bill" and "Gates" in the HTML form above, the URL sent to theserver would look like this:
http://www.w3schools.com/simpleform.asp?fname=Bill&lname=GatesAssume that "simpleform.asp" contains the following ASP script:WelcomeThe browser will display the following in the body of the document:Welcome Bill Gates
Request.Form
The Request.Form command is used to collect values in a form with method="post".Information sent from a form with the POST method is invisible to others and has nolimits on the amount of information to send.If a user typed "Bill" and "Gates" in the HTML form above, the URL sent to the serverwould look like this:http://www.w3schools.com/simpleform.asp
Assume that "simpleform.asp" contains the following ASP script:WelcomeThe browser will display the following in the body of the document:Welcome Bill Gates
Form ValidationUser input should be validated on the browser whenever possible (by client scripts).Browser validation is faster and reduces the server load.You should consider server validation if the user input will be inserted into a database.A good way to validate a form on the server is to post the form to itself, instead ofjumping to a different page. The user will then get the error messages on the same pageas the form. This makes it easier to discover the error.
ASP Cookies
A cookie is often used to identify a user.
What is a Cookie?
A cookie is often used to identify a user. A cookie is a small file that the server embedson the user's computer. Each time the same computer requests a page with a browser, itwill send the cookie too. With ASP, you can both create and retrieve cookie values.
How to Create a Cookie?
The "Response.Cookies" command is used to create cookies.Note: The Response.Cookies command must appear BEFORE the tag.In the example below, we will create a cookie named "firstname" and assign the value
"Alex" to it:5
-
8/3/2019 Cuadernillo ASP
6/35
It is also possible to assign properties to a cookie, like setting a date when thecookie should expire:
How to Retrieve a Cookie Value?
The "Request.Cookies" command is used to retrieve a cookie value.In the example below, we retrieve the value of the cookie named "firstname"and display it on a page:
Output: Firstname=Alex
A Cookie with Keys
If a cookie contains a collection of multiple values, we say that the cookie hasKeys.In the example below, we will create a cookie collection named "user". The"user" cookie has Keys that contains information about a user:
Read all Cookies
Look at the following code:
Assume that your server has sent all the cookies above to a user.Now we want to read all the cookies sent to a user. The example below shows how todo it (note that the code below checks if a cookie has Keys with the HasKeysproperty):
Output:
firstname=Alexuser:firstname=Johnuser:lastname=Smithuser:country=Norwayuser:age=25
What if a Browser Does NOT Support Cookies?
If your application deals with browsers that do not support cookies, you will have touse other methods to pass information from one page to another in your application.There are two ways of doing this:
1. Add parameters to a URL
You can add parameters to a URL:Go to Welcome PageAnd retrieve the values in the "welcome.asp" file like this:
-
8/3/2019 Cuadernillo ASP
7/35
lname=Request.querystring("lname")response.write("
Hello " & fname & " " & lname & "!
")response.write("Welcome to my Web site!
")%>2. Use a form
You can use a form. The form passes the user input to "welcome.asp" when theuser clicks on the Submit button:First Name: Last Name: Retrieve the values in the "welcome.asp" file like this:
ASP Session Object
A Session object stores information about, or change settings for a user session.
The Session object
When you are working with an application on your computer, you open it, dosome 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 youclose it. However, on the internet there is one problem: the web server does notknow who you are and what you do, because the HTTP address doesn't maintainstate.ASP solves this problem by creating a unique cookie for each user. The cookieis 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 usersession.Variables stored in a Session object hold information about one single user, andare available to all pages in one application. Common information stored insession variables are name, id, and preferences. The server creates a new
Session object for each new user, and destroys the Session object when the sessionexpires.
When does a Session Start?
A session starts when:
A new user requests an ASP file, and the Global.asa file includes a
Session_OnStart procedure A value is stored in a Session variable
A user requests an ASP file, and the Global.asa file uses the tag toinstantiate an object with session scope
When does a Session End?
A session ends if a user has not requested or refreshed a page in the application for aspecified period. By default, this is 20 minutes.If you want to set a timeout interval that is shorter or longer than the default, use theTimeout property.
The example below sets a timeout interval of 5 minutes:Use the Abandon method to end a session immediately:Note: The main problem with sessions is WHEN they should end. We do not know ifthe user's last request was the final one or not. So we do not know how long we shouldkeep the session "alive". Waiting too long for an idle session uses up resources on theserver, but if the session is deleted too soon the user has to start all over again because
the server has deleted all the information. Finding the right timeout interval can bedifficult!
Tip: Only store SMALL amounts of data in session variables!
Store and Retrieve Session Variables
The most important thing about the Session object is that you can store variables in it.The example below will set the Session variable username to "Donald Duck" and theSession variable age to "50":
7
-
8/3/2019 Cuadernillo ASP
8/35
When the value is stored in a session variable it can be reached from ANY pagein the ASP application:Welcome The line above returns: "Welcome Donald Duck".You can also store user preferences in the Session object, and then access thatpreference to choose what page to return to the user.The example below specifies a text-only version of the page if the user has a lowscreen resolution:
This is the text version of the page
This is the multimedia version of the page
Remove Session Variables
The Contents collection contains all session variables.It is possible to remove a session variable with the Remove method.The example below removes the session variable "sale" if the value of the
session variable "age" is lower than 18:
-
8/3/2019 Cuadernillo ASP
9/35
The Application object holds information that will be used by many pages in theapplication (like database connection information). The information can beaccessed from any page. The information can also be changed in one place, andthe changes will automatically be reflected on all pages.
Store and Retrieve Application Variables
Application variables can be accessed and changed by any page in an
application.You can create Application variables in "Global.asa" like this:
Sub Application_OnStartapplication("vartime")=""application("users")=1End Sub
In the example above we have created two Application variables: "vartime" and"users".
You can access the value of an Application variable like this:There areactive connections.
Loop Through the Contents Collection
The Contents collection contains all application variables. You can loop throughthe Contents collection, to see what's stored in it:If you do not know the number of items in the Contents collection, you can usethe Count property:
Loop Through the StaticObjects Collection
You can loop through the StaticObjects collection, to see the values of all objectsstored in the Application object:
Lock and Unlock
You can lock an application with the "Lock" method. When an application is locked,the users cannot change the Application variables (other than the one currentlyaccessing it). You can unlock an application with the "Unlock" method. This method
removes the lock from the Application variable:
-
8/3/2019 Cuadernillo ASP
10/35
Here is the "wisdom.inc" file:"One should never increase, beyond what is necessary,the number of entities required to explain anything."Here is the "time.inc" file:If you look at the source code in a browser, it will look something like this:Words of Wisdom:
"One should never increase, beyond what is necessary,the number of entities required to explain anything."
The time is:11:33:42 AM
Syntax for Including Files
To include a file in an ASP page, place the #include directive inside commenttags:
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, thefollowing line would insert the contents of "header.inc":
The File Keyword
Use the file keyword to indicate a relative path. A relative path begins with thedirectory that contains the including file.If you have a file in the html directory, and the file "header.inc" resides inhtml\headers, the following line would insert "header.inc" in your file:
Note that the path to the included file (headers\header.inc) is relative to the includingfile. If the file containing this #include statement is not in the html directory, thestatement will not work.
Tips and Notes
In the sections above we have used the file extension ".inc" for included files. Notice
that if a user tries to browse an INC file directly, its content will be displayed. If yourincluded file contains confidential information or information you do not want anyusers to see, it is better to use an ASP extension. The source code in an ASP file willnot be visible after the interpretation. An included file can also include other files, andone ASP file can include the same file more than once.Important: Included files are processed and inserted before the scripts are executed.The following script will NOT work because ASP executes the #include directivebefore it assigns a value to the variable:
You cannot open or close a script delimiter in an INC file. The following script willNOT work:
ASP 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 usedwithin Global.asa.The Global.asa file can contain only the following:
Application events
Session events
10
-
8/3/2019 Cuadernillo ASP
11/35
declarations
TypeLibrary declarations
the #include directive
Note: The Global.asa file must be stored in the root directory of the ASPapplication, and each application can only have one Global.asa file.
Events in Global.asa
In Global.asa you can tell the application and session objects what to do whenthe application/session starts and what to do when the application/session ends.The code for this is placed in event handlers. The Global.asa file can containfour types of events:Application_OnStart - Occurs when the FIRST user calls the first page in anASP application. This event occurs after the Web server is restarted or after theGlobal.asa file is edited. The "Session_OnStart" event occurs immediately afterthis event.Session_OnStart - This event occurs EVERY time a NEW user requests his orher first page in the ASP application.Session_OnEnd - This event occurs EVERY time a user ends a session. A user-
session ends 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 thesession. Typically, this event occurs when a Web server stops. This procedure isused to clean up settings after the Application stops, like delete records or writeinformation to text files.A Global.asa file could look something like this:
sub Application_OnStart'some codeend sub
sub Application_OnEnd'some codeend sub
sub Session_OnStart'some codeend sub
sub Session_OnEnd'some codeend sub
Note: Because we cannot use the ASP script delimiters () to insert scriptsin the Global.asa file, we put subroutines inside an HTML element.
Declarations
It is possible to create objects with session or application scope in Global.asa by usingthe tag.
Note: The tag should be outside the tag!
Syntax
....
Parameter Description
scope Sets the scope of the object (either Session or Application)
id Specifies a unique id for the objectProgID 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.
Either ProgID or ClassID must be specified.
Examples
The first example creates an object of session scope named "MyAd" by using theProgID parameter:The second example creates an object of application scope named "MyConnection" byusing the ClassID parameter:The objects declared in the Global.asa file can be used by any script in the application:GLOBAL.ASA:
11
-
8/3/2019 Cuadernillo ASP
12/35
You could reference the object "MyAd" from any page in the ASP application:
SOME .ASP FILE:
TypeLibrary Declarations
A TypeLibrary is a container for the contents of a DLL file corresponding to aCOM object. By including a call to the TypeLibrary in the Global.asa file, theconstants of the COM object can be accessed, and errors can be better reportedby the ASP code. If your Web application relies on COM objects that havedeclared data types in type libraries, you can declare the type libraries inGlobal.asa.
Syntax
Parameter Description
file Specifies an absolute path to a type library.
Either the file parameter or the uuid parameter is required
uuid Specifies a unique identifier for the type library.
Either the file parameter or the uuid parameter is required
version Optional. Used for selecting version. If the requested version isnot found, then the most recent version is used
lcid Optional. The locale identifier to be used for the type library
Error Values
The server can return one of the following error messages:
Error Code Description
ASP 0222 Invalid type library specification
ASP 0223 Type library not found
ASP 0224 Type library cannot be loaded
ASP 0225 Type library cannot be wrapped
Note: METADATA tags can appear anywhere in the Global.asa file (both inside andoutside tags). However, it is recommended that METADATA tags appear nearthe top of the Global.asa file.
Restrictions
Restrictions on what you can include in the Global.asa file:
You cannot display text written in the Global.asa file. This file can't displayinformation
You can only use Server and Application objects in the Application_OnStartand Application_OnEnd subroutines. In the Session_OnEnd subroutine, youcan use Server, Application, and Session objects. In the Session_OnStartsubroutine you can use any built-in object
How to use the Subroutines
Global.asa is often used to initialize variables.The example below shows how to detect the exact time a visitor first arrives on a Website. 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_OnStartSession("started")=now()end sub
Global.asa can also be used to control page access.The example below shows how to redirect every new visitor to another page, in thiscase to a page called "newpage.asp":sub Session_OnStartResponse.Redirect("newpage.asp")end subAnd you can include functions in the Global.asa file.In the example below the Application_OnStart subroutine occurs when the Web serverstarts. Then the Application_OnStart subroutine calls another subroutine named"getcustomers". The "getcustomers" subroutine opens a database and retrieves a record
12
-
8/3/2019 Cuadernillo ASP
13/35
set from the "customers" table. The record set is assigned to an array, where itcan be accessed from any ASP page without querying the database:
sub Application_OnStartgetcustomersend sub
sub getcustomersset conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:/webdata/northwind.mdb"set rs=conn.execute("select name from customers")Application("customers")=rs.GetRowsrs.Closeconn.Closeend sub
Global.asa Example
In this example we will create a Global.asa file that counts the number of currentvisitors.
The Application_OnStart sets the Application variable "visitors" to 0when 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 timethis subroutine is triggered
The Global.asa file:
Sub Application_OnStartApplication("visitors")=0End Sub
Sub Session_OnStartApplication.LockApplication("visitors")=Application("visitors")+1Application.UnLock
End Sub
Sub Session_OnEndApplication.LockApplication("visitors")=Application("visitors")-1Application.UnLockEnd Sub
To display the number of current visitors in an ASP file:
There are online now!
ASP Sending e-mail with CDOSYS
Previous Next Chapter
CDOSYS is a built-in component in ASP. This component is used to send e-mails withASP.
Sending e-mail with CDOSYS
CDO (Collaboration Data Objects) is a Microsoft technology that is designed tosimplify the creation of messaging applications.CDOSYS is a built-in component in ASP. We will show you how to use thiscomponent to send e-mail with ASP.
How about CDONTs?
Microsoft has discontinued the use of CDONTs on Windows 2000, Windows XP andWindows 2003. If you have used CDONTs in your ASP applications, you shouldupdate the code and use the new CDO technology.
Examples using CDOSYS
Sending a text e-mail:
-
8/3/2019 Cuadernillo ASP
14/35
myMail.To="[email protected]"myMail.TextBody="This is a message."myMail.Sendset myMail=nothing%>Sending a text e-mail with Bcc and CC fields:Sending an HTML e-mail:Sending an HTML e-mail that sends a webpage from a website:Sending an HTML e-mail that sends a webpage from a file on your computer:Sending a text e-mail with an Attachment:Sending a text e-mail using a remote server:
ASP Response Object
The ASP Response object is used to send output to the user from the server.
Response Object
The ASP Response object is used to send output to the user from the server. Itscollections, properties, and methods are described below:
Collections
14
-
8/3/2019 Cuadernillo ASP
15/35
Collection Description
Cookies Sets a cookie value. If the cookie does not exist, it will becreated, 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 generatedby ASP or not
Charset Appends the name of a character-set to the content-typeheader 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 abrowser before it expires
ExpiresAbsolute Sets a date and time when a page cached on a browser willexpire
IsClientConnected Indicates if the client has disconnected from the serverPics 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
conversionClear 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
ASP Request Object
The Request object is used to get information from a visitor.
Request Object
When a browser asks for a page from a server, it is called a request. The Request objectis used to get information from a visitor. Its collections, properties, and methods aredescribed 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 thepost method
QueryString Contains all the variable values in a HTTP query string
ServerVariables Contains all the server variable values
Properties
Property Description
TotalBytes Returns the total number of bytes the client sent in the bodyof the request
Methods
Method Description
BinaryRead Retrieves the data sent to the server from the client as part ofa post request and stores it in a safe array
ASP Application Object
A group of ASP files that work together to perform some purpose is called anapplication. The Application object is used to tie these files together.
Application Object
An application on the Web may consists of several ASP files that work together toperform some purpose. The Application object is used to tie these files together.
15
http://www.w3schools.com/ASP/coll_cookies_response.asphttp://www.w3schools.com/ASP/prop_buffer.asphttp://www.w3schools.com/ASP/prop_cachecontrol.asphttp://www.w3schools.com/ASP/prop_charset.asphttp://www.w3schools.com/ASP/prop_contenttype.asphttp://www.w3schools.com/ASP/prop_expires.asphttp://www.w3schools.com/ASP/prop_expiresabsolute.asphttp://www.w3schools.com/ASP/prop_isclientconnected.asphttp://www.w3schools.com/ASP/prop_pics.asphttp://www.w3schools.com/ASP/prop_status.asphttp://www.w3schools.com/ASP/met_addheader.asphttp://www.w3schools.com/ASP/met_appendtolog.asphttp://www.w3schools.com/ASP/met_binarywrite.asphttp://www.w3schools.com/ASP/met_clear.asphttp://www.w3schools.com/ASP/met_end.asphttp://www.w3schools.com/ASP/met_flush.asphttp://www.w3schools.com/ASP/met_redirect.asphttp://www.w3schools.com/ASP/met_write_response.asphttp://www.w3schools.com/ASP/coll_cookies_request.asphttp://www.w3schools.com/ASP/coll_form.asphttp://www.w3schools.com/ASP/coll_querystring.asphttp://www.w3schools.com/ASP/coll_servervariables.asphttp://www.w3schools.com/ASP/prop_totalbytes.asphttp://www.w3schools.com/ASP/met_binaryread.asphttp://www.w3schools.com/ASP/coll_cookies_response.asphttp://www.w3schools.com/ASP/prop_buffer.asphttp://www.w3schools.com/ASP/prop_cachecontrol.asphttp://www.w3schools.com/ASP/prop_charset.asphttp://www.w3schools.com/ASP/prop_contenttype.asphttp://www.w3schools.com/ASP/prop_expires.asphttp://www.w3schools.com/ASP/prop_expiresabsolute.asphttp://www.w3schools.com/ASP/prop_isclientconnected.asphttp://www.w3schools.com/ASP/prop_pics.asphttp://www.w3schools.com/ASP/prop_status.asphttp://www.w3schools.com/ASP/met_addheader.asphttp://www.w3schools.com/ASP/met_appendtolog.asphttp://www.w3schools.com/ASP/met_binarywrite.asphttp://www.w3schools.com/ASP/met_clear.asphttp://www.w3schools.com/ASP/met_end.asphttp://www.w3schools.com/ASP/met_flush.asphttp://www.w3schools.com/ASP/met_redirect.asphttp://www.w3schools.com/ASP/met_write_response.asphttp://www.w3schools.com/ASP/coll_cookies_request.asphttp://www.w3schools.com/ASP/coll_form.asphttp://www.w3schools.com/ASP/coll_querystring.asphttp://www.w3schools.com/ASP/coll_servervariables.asphttp://www.w3schools.com/ASP/prop_totalbytes.asphttp://www.w3schools.com/ASP/met_binaryread.asp -
8/3/2019 Cuadernillo ASP
16/35
The Application object is used to store and access variables from any page, justlike the Session object. The difference is that ALL users share ONE Applicationobject (with Sessions there is ONE Session object for EACH user).The Application object holds information that will be used by many pages in theapplication (like database connection information). The information can beaccessed from any page. The information can also be changed in one place, andthe 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 applicationthrough a script command
StaticObjects Contains all the objects appended to the application withthe HTML tag
Methods
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 theApplication object
Unlock Enables other users to modify the variables in theApplication object (after it has been locked using theLock method)
Events
Event Description
Application_OnEnd Occurs when all user sessions are over, and theapplication ends
Application_OnStart Occurs before the first new session is created (when theApplication object is first referenced)
ASP Session Object
A Session object stores information about, or change settings for a user session.
Session Object
When you are working with an application on your computer, you open it, do somechanges and then you close it. This is much like a Session. The computer knows whoyou are. It knows when you open the application and when you close it. However, onthe internet there is one problem: the web server does not know who you are and whatyou 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 interfaceis 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 areavailable to all pages in one application. Common information stored in sessionvariables are name, id, and preferences. The server creates a new Session object foreach new user, and destroys the Session object when the session expires.The Session object's collections, properties, methods, and events are described below:
Collections
Collection Description
Contents Contains all the items appended to the session througha script command
StaticObjects Contains all the objects appended to the session withthe HTML tag
Properties
Property Description
CodePage Specifies the character set that will be used whendisplaying dynamic content
LCID Sets or returns an integer that specifies a location orregion. Contents like date, time, and currency will bedisplayed according to that location or region
SessionID Returns a unique id for each user. The unique id isgenerated by the server
Timeout Sets or returns the timeout period (in minutes) for theSession object in this application
Methods
Method Description
16
http://www.w3schools.com/ASP/coll_contents_app.asphttp://www.w3schools.com/ASP/coll_staticobjects_app.asphttp://www.w3schools.com/ASP/met_contents_remove_app.asphttp://www.w3schools.com/ASP/met_contents_removeall_app.asphttp://www.w3schools.com/ASP/met_lock_unlock.asphttp://www.w3schools.com/ASP/met_lock_unlock.asphttp://www.w3schools.com/ASP/ev_app_onend_onstart.asphttp://www.w3schools.com/ASP/ev_app_onend_onstart.asphttp://www.w3schools.com/ASP/coll_contents_sess.asphttp://www.w3schools.com/ASP/coll_staticobjects_sess.asphttp://www.w3schools.com/ASP/prop_codepage.asphttp://www.w3schools.com/ASP/prop_lcid.asphttp://www.w3schools.com/ASP/prop_sessionid.asphttp://www.w3schools.com/ASP/prop_timeout.asphttp://www.w3schools.com/ASP/coll_contents_app.asphttp://www.w3schools.com/ASP/coll_staticobjects_app.asphttp://www.w3schools.com/ASP/met_contents_remove_app.asphttp://www.w3schools.com/ASP/met_contents_removeall_app.asphttp://www.w3schools.com/ASP/met_lock_unlock.asphttp://www.w3schools.com/ASP/met_lock_unlock.asphttp://www.w3schools.com/ASP/ev_app_onend_onstart.asphttp://www.w3schools.com/ASP/ev_app_onend_onstart.asphttp://www.w3schools.com/ASP/coll_contents_sess.asphttp://www.w3schools.com/ASP/coll_staticobjects_sess.asphttp://www.w3schools.com/ASP/prop_codepage.asphttp://www.w3schools.com/ASP/prop_lcid.asphttp://www.w3schools.com/ASP/prop_sessionid.asphttp://www.w3schools.com/ASP/prop_timeout.asp -
8/3/2019 Cuadernillo ASP
17/35
Abandon Destroys a user session
Contents.Remove Deletes an item from the Contents collection
Contents.RemoveAll() Deletes all items from the Contents collection
Events
Event DescriptionSession_OnEnd Occurs when a session ends
Session_OnStart Occurs when a session starts
ASP ServerObject
The Server object is used to access properties and methods on the server.
Server Object
The ASP Server object is used to access properties and methods on the server.Its properties and methods are described below:
Properties
Property Description
ScriptTimeout Sets or returns the maximum number of seconds a script canrun before it is terminated
Methods
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 conditionthat 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 fileto a second ASP file
URLEncode Applies URL encoding rules to a specified string
ASP ASPErrorObject
The ASPError object displays information about errors in scripts.
The ASPError Object
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 inscripts in an ASP page.Note: The ASPError object is created when Server.GetLastError is called, so the errorinformation can only be accessed by using the Server.GetLastError method.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 isASP-related)
Category Returns the source of the error (was the error generated byASP? By a scripting language? By an object?)
Column Returns the column position within the file that generated theerror
Description 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
ASP FileSystemObject Object
The FileSystemObject object is used to access the file system on a server.
The FileSystemObject Object
The FileSystemObject object is used to access the file system on a server.This object can manipulate files, folders, and directory paths. It is also possible toretrieve file system information with this object.The following code creates a text file (c:\test.txt) and then writes some text to the file:
17
http://www.w3schools.com/ASP/met_abandon.asphttp://www.w3schools.com/ASP/met_contents_remove_sess.asphttp://www.w3schools.com/ASP/met_contents_removeall_sess.asphttp://www.w3schools.com/ASP/ev_sess_onend_onstart.asphttp://www.w3schools.com/ASP/ev_sess_onend_onstart.asphttp://www.w3schools.com/ASP/prop_scripttimeout.asphttp://www.w3schools.com/ASP/met_createobject_server.asphttp://www.w3schools.com/ASP/met_execute.asphttp://www.w3schools.com/ASP/met_getlasterror.asphttp://www.w3schools.com/ASP/met_htmlencode.asphttp://www.w3schools.com/ASP/met_mappath.asphttp://www.w3schools.com/ASP/met_transfer.asphttp://www.w3schools.com/ASP/met_urlencode.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/met_abandon.asphttp://www.w3schools.com/ASP/met_contents_remove_sess.asphttp://www.w3schools.com/ASP/met_contents_removeall_sess.asphttp://www.w3schools.com/ASP/ev_sess_onend_onstart.asphttp://www.w3schools.com/ASP/ev_sess_onend_onstart.asphttp://www.w3schools.com/ASP/prop_scripttimeout.asphttp://www.w3schools.com/ASP/met_createobject_server.asphttp://www.w3schools.com/ASP/met_execute.asphttp://www.w3schools.com/ASP/met_getlasterror.asphttp://www.w3schools.com/ASP/met_htmlencode.asphttp://www.w3schools.com/ASP/met_mappath.asphttp://www.w3schools.com/ASP/met_transfer.asphttp://www.w3schools.com/ASP/met_urlencode.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asphttp://www.w3schools.com/ASP/prop_asperrorobject.asp -
8/3/2019 Cuadernillo ASP
18/35
The FileSystemObject object's properties and methods are described below:
Properties
Property Description
Drives Returns a collection of all Drive objects on thecomputer
Methods
Method Description
BuildPath Appends a name to an existing path
CopyFile Copies one or more files from one location to another
CopyFolder Copies one or more folders from one location toanother
CreateFolder Creates a new folder
CreateTextFile Creates a text file and returns a TextStream object thatcan be used to read from, or write to the file
DeleteFile Deletes one or more specified files
DeleteFolder Deletes one or more specified folders
DriveExists Checks if a specified drive exists
FileExists Checks if a specified file exists
FolderExists Checks if a specified folder exists
GetAbsolutePathName Returns the complete path from the root of the drive forthe specified path
GetBaseName Returns the base name of a specified file or folder
GetDrive Returns a Drive object corresponding to the drive in aspecified path
GetDriveName Returns the drive name of a specified path
GetExtensionName Returns the file extension name for the last componentin a specified path
GetFile Returns a File object for a specified path
GetFileName Returns the file name or folder name for the lastcomponent in a specified path
GetFolder Returns a Folder object for a specified path
GetParentFolderName Returns the name of the parent folder of the last
component in a specified path
GetSpecialFolder Returns the path to some of Windows' special folders
GetTempName Returns a randomly generated temporary file or folder
MoveFile Moves one or more files from one location to another
MoveFolder Moves one or more folders from one location toanother
OpenTextFile Opens a file and returns a TextStream object that canbe used to access the file
ASP TextStream Object
Previous Next Chapter
The TextStream object is used to access the contents of a text file.
The TextStream Object
The TextStream object is used to access the contents of text files.The following code creates a text file (c:\test.txt) and then writes some text to the file(the variable f is an instance of the TextStream object):To create an instance of the TextStream object you can use the CreateTextFile orOpenTextFile methods of the FileSystemObject object, or you can use theOpenAsTextStream method of the File object.The TextStream object's properties and methods are described below:
Properties
18
http://www.w3schools.com/ASP/prop_drives.asphttp://www.w3schools.com/ASP/met_buildpath.asphttp://www.w3schools.com/ASP/met_copyfile.asphttp://www.w3schools.com/ASP/met_copyfolder.asphttp://www.w3schools.com/ASP/met_createfolder.asphttp://www.w3schools.com/ASP/met_createtextfile_filesystem.asphttp://www.w3schools.com/ASP/met_deletefile.asphttp://www.w3schools.com/ASP/met_deletefolder.asphttp://www.w3schools.com/ASP/met_driveexists.asphttp://www.w3schools.com/ASP/met_fileexists.asphttp://www.w3schools.com/ASP/met_folderexists.asphttp://www.w3schools.com/ASP/met_getabsolutepathname.asphttp://www.w3schools.com/ASP/met_getbasename.asphttp://www.w3schools.com/ASP/met_getdrive.asphttp://www.w3schools.com/ASP/met_getdrivename.asphttp://www.w3schools.com/ASP/met_getextensionname.asphttp://www.w3schools.com/ASP/met_getfile.asphttp://www.w3schools.com/ASP/met_getfilename.asphttp://www.w3schools.com/ASP/met_getfolder.asphttp://www.w3schools.com/ASP/met_getparentfoldername.asphttp://www.w3schools.com/ASP/met_getspecialfolder.asphttp://www.w3schools.com/ASP/met_gettempname.asphttp://www.w3schools.com/ASP/met_movefile.asphttp://www.w3schools.com/ASP/met_movefolder.asphttp://www.w3schools.com/ASP/met_opentextfile.asphttp://www.w3schools.com/ASP/asp_ref_filesystem.asphttp://www.w3schools.com/ASP/asp_ref_drive.asphttp://www.w3schools.com/ASP/prop_drives.asphttp://www.w3schools.com/ASP/met_buildpath.asphttp://www.w3schools.com/ASP/met_copyfile.asphttp://www.w3schools.com/ASP/met_copyfolder.asphttp://www.w3schools.com/ASP/met_createfolder.asphttp://www.w3schools.com/ASP/met_createtextfile_filesystem.asphttp://www.w3schools.com/ASP/met_deletefile.asphttp://www.w3schools.com/ASP/met_deletefolder.asphttp://www.w3schools.com/ASP/met_driveexists.asphttp://www.w3schools.com/ASP/met_fileexists.asphttp://www.w3schools.com/ASP/met_folderexists.asphttp://www.w3schools.com/ASP/met_getabsolutepathname.asphttp://www.w3schools.com/ASP/met_getbasename.asphttp://www.w3schools.com/ASP/met_getdrive.asphttp://www.w3schools.com/ASP/met_getdrivename.asphttp://www.w3schools.com/ASP/met_getextensionname.asphttp://www.w3schools.com/ASP/met_getfile.asphttp://www.w3schools.com/ASP/met_getfilename.asphttp://www.w3schools.com/ASP/met_getfolder.asphttp://www.w3schools.com/ASP/met_getparentfoldername.asphttp://www.w3schools.com/ASP/met_getspecialfolder.asphttp://www.w3schools.com/ASP/met_gettempname.asphttp://www.w3schools.com/ASP/met_movefile.asphttp://www.w3schools.com/ASP/met_movefolder.asphttp://www.w3schools.com/ASP/met_opentextfile.asphttp://www.w3schools.com/ASP/asp_ref_filesystem.asphttp://www.w3schools.com/ASP/asp_ref_drive.asp -
8/3/2019 Cuadernillo ASP
19/35
Property Description
AtEndOfLine Returns true if the file pointer is positioned immediatelybefore the end-of-line marker in a TextStream file, and falseif not
AtEndOfStream Returns true if the file pointer is at the end of a TextStreamfile, and false if not
Column Returns the column number of the current character position
in an input streamLine Returns the current line number in a TextStream file
Methods
Method Description
Close Closes an open TextStream file
Read Reads a specified number of characters from a TextStreamfile and returns the result
ReadAll Reads an entire TextStream file and returns the result
ReadLine Reads one line from a TextStream file and returns the resultSkip Skips a specified number of characters when reading a
TextStream file
SkipLine Skips the next line when reading a TextStream file
Write Writes a specified text to a TextStream file
WriteLine Writes a specified text and a new-line character to aTextStream file
WriteBlankLines Writes a specified number of new-line character to aTextStream file
The Drive Object
The Drive object is used to return information about a local disk drive or anetwork share. The Drive object can return information about a drive's type offile system, free space, serial number, volume name, and more.Note: You cannot return information about a drive's content with the Driveobject. For this purpose you will have to use the Folder object.To work with the properties of the Drive object, you will have to create aninstance of the Drive object through the FileSystemObject object. First; create aFileSystemObject object and then instantiate the Drive object through theGetDrive method or the Drives property of the FileSystemObject object.The Drive object's properties are described below:
Properties
Property Description
AvailableSpace Returns the amount of available space to a user on aspecified drive or network share
DriveLetter Returns one uppercase letter that identifies the local drive ora network share
DriveType Returns the type of a specified drive
FileSystem Returns the file system in use for a specified drive
FreeSpace Returns the amount of free space to a user on a specifieddrive or network share
IsReady Returns true if the specified drive is ready and false if not
Path Returns an uppercase letter followed by a colon that indicatesthe path name for a specified drive
RootFolder Returns a Folder object that represents the root folder of aspecified drive
SerialNumber Returns the serial number of a specified drive
ShareName Returns the network share name for a specified drive
TotalSize Returns the total size of a specified drive or network share
VolumeName Sets or returns the volume name of a specified drive
ASP File Object
The File object is used to return information about a specified file.
The File Object
The File object is used to return information about a specified file.To work with the properties and methods of the File object, you will have to create aninstance of the File object through the FileSystemObject object. First; create aFileSystemObject object and then instantiate the File object through the GetFilemethod of the FileSystemObject object or through the Files property of the Folderobject.The following code uses the GetFile method of the FileSystemObject object toinstantiate the File object and the DateCreated property to return the date when thespecified file was created:
Example
-
8/3/2019 Cuadernillo ASP
20/35
Response.Write("File created: " & f.DateCreated)set f=nothingset fs=nothing%>
The File object's properties and methods are described below:
Properties
Property Description
Attributes Sets or returns the attributes of a specified file
DateCreated Returns the date and time when a specified file wascreated
DateLastAccessed Returns the date and time when a specified file was lastaccessed
DateLastModified Returns the date and time when a specified file was last
modifiedDrive Returns the drive letter of the drive where a specified file
or folder resides
Name Sets or returns the name of a specified file
ParentFolder Returns the folder object for the parent of the specified file
Path Returns the path for a specified file
ShortName Returns the short name of a specified file (the 8.3 namingconvention)
ShortPath Returns the short path of a specified file (the 8.3 namingconvention)
Size Returns the size, in bytes, of a specified file
Type Returns the type of a specified file
Methods
Method Description
Copy Copies a specified file from one location to another
Delete Deletes a specified file
Move Moves a specified file from one location to another
OpenAsTextStream Opens a specified file and returns a TextStream object toaccess the file
ASP FolderObject
Previous Next Chapter
The Folder Object is used to return information about a specified folder.
The Folder Object
The Folder object is used to return information about a specified folder.To work with the properties and methods of the Folder object, you will have to createan instance of the Folder object through the FileSystemObject object. First; create aFileSystemObject object and then instantiate the Folder object through the GetFoldermethod of the FileSystemObject object.The following code uses the GetFolder method of the FileSystemObject object toinstantiate the Folder object and the DateCreated property to return the date when thespecified folder was created:
Output:
Folder created: 10/22/2008 10:01:19 AMThe Folder object's collections, properties, and methods are described below:
Collections
Collection Description
Files Returns a collection of all the files in a specified folder
SubFolders Returns a collection of all subfolders in a specified folder
Properties
Property Description
Attributes Sets or returns the attributes of a specified folder
DateCreated Returns the date and time when a specified folder was
20
http://www.w3schools.com/ASP/prop_attributes_file.asphttp://www.w3schools.com/ASP/prop_datecreated_file.asphttp://www.w3schools.com/ASP/prop_datelastaccessed_file.asphttp://www.w3schools.com/ASP/prop_datelastmodified_file.asphttp://www.w3schools.com/ASP/prop_drive_file.asphttp://www.w3schools.com/ASP/prop_name_file.asphttp://www.w3schools.com/ASP/prop_parentfolder_file.asphttp://www.w3schools.com/ASP/prop_path_file.asphttp://www.w3schools.com/ASP/prop_shortname_file.asphttp://www.w3schools.com/ASP/prop_shortpath_file.asphttp://www.w3schools.com/ASP/prop_size_file.asphttp://www.w3schools.com/ASP/prop_type_file.asphttp://www.w3schools.com/ASP/met_copy_file.asphttp://www.w3schools.com/ASP/met_delete_file.asphttp://www.w3schools.com/ASP/met_move_file.asphttp://www.w3schools.com/ASP/met_openastextstream.asphttp://www.w3schools.com/ASP/met_openastextstream.asphttp://www.w3schools.com/ASP/asp_ref_file.asphttp://www.w3schools.com/ASP/asp_ref_dictionary.asphttp://www.w3schools.com/ASP/coll_files.asphttp://www.w3schools.com/ASP/coll_subfolders.asphttp://www.w3schools.com/ASP/prop_attributes_folder.asphttp://www.w3schools.com/ASP/prop_datecreated_folder.asphttp://www.w3schools.com/ASP/prop_attributes_file.asphttp://www.w3schools.com/ASP/prop_datecreated_file.asphttp://www.w3schools.com/ASP/prop_datelastaccessed_file.asphttp://www.w3schools.com/ASP/prop_datelastmodified_file.asphttp://www.w3schools.com/ASP/prop_drive_file.asphttp://www.w3schools.com/ASP/prop_name_file.asphttp://www.w3schools.com/ASP/prop_parentfolder_file.asphttp://www.w3schools.com/ASP/prop_path_file.asphttp://www.w3schools.com/ASP/prop_shortname_file.asphttp://www.w3schools.com/ASP/prop_shortpath_file.asphttp://www.w3schools.com/ASP/prop_size_file.asphttp://www.w3schools.com/ASP/prop_type_file.asphttp://www.w3schools.com/ASP/met_copy_file.asphttp://www.w3schools.com/ASP/met_delete_file.asphttp://www.w3schools.com/ASP/met_move_file.asphttp://www.w3schools.com/ASP/met_openastextstream.asphttp://www.w3schools.com/ASP/asp_ref_file.asphttp://www.w3schools.com/ASP/asp_ref_dictionary.asphttp://www.w3schools.com/ASP/coll_files.asphttp://www.w3schools.com/ASP/coll_subfolders.asphttp://www.w3schools.com/ASP/prop_attributes_folder.asphttp://www.w3schools.com/ASP/prop_datecreated_folder.asp -
8/3/2019 Cuadernillo ASP
21/35
created
DateLastAccessed Returns the date and time when a specified folder was lastaccessed
DateLastModified Returns the date and time when a specified folder was lastmodified
Drive Returns the drive letter of the drive where the specifiedfolder resides
IsRootFolder Returns true if a folder is the root folder and false if not
Name Sets or returns the name of a specified folder
ParentFolder Returns the parent folder of a specified folder
Path Returns the path for a specified folder
ShortName Returns the short name of a specified folder (the 8.3 namingconvention)
ShortPath Returns the short path of a specified folder (the 8.3 namingconvention)
Size Returns the size of a specified folder
Type Returns the type of a specified folder
Methods
Method Description
Copy Copies a specified folder from one location to another
Delete Deletes a specified folder
Move Moves a specified folder from one location to another
CreateTextFile Creates a new text file in the specified folder and returns aTextStream object to access the file
ASP Dictionary Object
The Dictionary object stores information in name/value pairs.
The Dictionary Object
The Dictionary object is used to store information in name/value pairs (referredto as key and item). The Dictionary object might seem similar to Arrays,however, the Dictionary object is a more desirable solution to manipulate relateddata.
Comparing Dictionaries and Arrays:
Keys are used to identify the items in a Dictionary object
You do not have to call ReDim to change the size of the Dictionary object
When deleting an item from a Dictionary, the remaining items willautomatically shift up
Dictionaries cannot be multidimensional, Arrays can
Dictionaries have more built-in functions than Arrays Dictionaries work better than arrays on accessing random elements frequently
Dictionaries work better than arrays on locating items by their content
The following example creates a Dictionary object, adds some key/item pairs to it, andretrieves the item value for the key gr:
Output:
The value of key gr is: GreenThe Dictionary object's properties and methods are described below:
Properties
Property DescriptionCompareMode Sets or returns the comparison mode for comparing keys in a
Dictionary object
Count Returns the number of key/item pairs in a Dictionary object
Item Sets or returns the value of an item in a Dictionary object
Key Sets a new key value for an existing key value in a Dictionaryobject
Methods
Method Description
21
http://www.w3schools.com/ASP/prop_datelastaccessed_folder.asphttp://www.w3schools.com/ASP/prop_datelastmodified_folder.asphttp://www.w3schools.com/ASP/prop_drive_folder.asphttp://www.w3schools.com/ASP/prop_isrootfolder.asphttp://www.w3schools.com/ASP/prop_name_folder.asphttp://www.w3schools.com/ASP/prop_parentfolder_folder.asphttp://www.w3schools.com/ASP/prop_path_folder.asphttp://www.w3schools.com/ASP/prop_shortname_folder.asphttp://www.w3schools.com/ASP/prop_shortpath_folder.asphttp://www.w3schools.com/ASP/prop_size_folder.asphttp://www.w3schools.com/ASP/prop_type_folder.asphttp://www.w3schools.com/ASP/met_copy_folder.asphttp://www.w3schools.com/ASP/met_delete_folder.asphttp://www.w3schools.com/ASP/met_move_folder.asphttp://www.w3schools.com/ASP/met_createtextfile_folder.asphttp://www.w3schools.com/ASP/prop_comparemode.asphttp://www.w3schools.com/ASP/prop_count.asphttp://www.w3schools.com/ASP/prop_item.asphttp://www.w3schools.com/ASP/prop_key.asphttp://www.w3schools.com/ASP/prop_datelastaccessed_folder.asphttp://www.w3schools.com/ASP/prop_datelastmodified_folder.asphttp://www.w3schools.com/ASP/prop_drive_folder.asphttp://www.w3schools.com/ASP/prop_isrootfolder.asphttp://www.w3schools.com/ASP/prop_name_folder.asphttp://www.w3schools.com/ASP/prop_parentfolder_folder.asphttp://www.w3schools.com/ASP/prop_path_folder.asphttp://www.w3schools.com/ASP/prop_shortname_folder.asphttp://www.w3schools.com/ASP/prop_shortpath_folder.asphttp://www.w3schools.com/ASP/prop_size_folder.asphttp://www.w3schools.com/ASP/prop_type_folder.asphttp://www.w3schools.com/ASP/met_copy_folder.asphttp://www.w3schools.com/ASP/met_delete_folder.asphttp://www.w3schools.com/ASP/met_move_folder.asphttp://www.w3schools.com/ASP/met_createtextfile_folder.asphttp://www.w3schools.com/ASP/prop_comparemode.asphttp://www.w3schools.com/ASP/prop_count.asphttp://www.w3schools.com/ASP/prop_item.asphttp://www.w3schools.com/ASP/prop_key.asp -
8/3/2019 Cuadernillo ASP
22/35
Add Adds a new key/item pair to a Dictionary object
Exists Returns a Boolean value that indicates whether a specified keyexists in the Dictionary object
Items Returns an array of all the items in a Dictionary object
Keys Returns an array of all the keys in a Dictionary object
Remove Removes one specified key/item pair from the Dictionaryobject
RemoveAll Removes all the key/item pairs in the Dictionary object
ASP ADO
ADO can be used to access databases from your web pages.
Accessing a Database from an ASP Page
The common way to access a database from inside an ASP page is to:
1. Create an ADO connection to a database
2. Open the database connection3. Create an ADO recordset4. Open the recordset5. Extract the data you need from the recordset6. Close the recordset7. Close the connection
What is ADO?
ADO is a Microsoft technology
ADO stands forActiveX Data Objects
ADO is a Microsoft Active-X component
ADO is automatically installed with Microsoft IIS
ADO is a programming interface to access data in a database
ASP AdRotatorComponent
Previous Next Chapter
ASP AdRotator Component
The ASP AdRotator component creates an AdRotator object that displays a differentimage each time a user enters or refreshes a page. A text file includes informationabout the images.
Syntax
ASP AdRotator Example
Assume that we have the following text file, named "ads.txt":REDIRECT banners.asp*w3s.gifhttp://www.w3schools.comFree Tutorials from W3Schools
50xmlspy.gifhttp://www.altova.comXML Editor from Altova50The lines below the asterisk in the text file above specifies the name of the images(ads) to be displayed, the hyperlink addresses, the alternate text (for the images), andthe display rates (in percent).The first line in the text file above specifies what to happen when a visitor clicks onone of the images. The redirection page (banners.asp) will receive a querystring withthe URL to redirect to.Tip: To specify the height, width, and border of the image, you can insert the
following lines under REDIRECT:REDIRECT banners.aspWIDTH 468HEIGHT 60BORDER 0*w3s.gif...The "banners.asp" file looks like this:
Example
-
8/3/2019 Cuadernillo ASP
23/35
url=Request.QueryString("url")If url"" then Response.Redirect(url)%>
That's all!!
ASP AdRotator Properties
Property Description Example
Border Specifies thesize of theborders aroundtheadvertisement
Clickable Specifieswhether theadvertisementis a hyperlink
TargetFrameName of the
frame todisplay theadvertisement
ASP AdRotator Methods
Method Description Example
GetAdvertisementReturnsHTML thatdisplays theadvertisementin the page
ASP Browser Capabilities Component
Previous Next Chapter
ASP Browser Capabilities Component
The ASP Browser Capabilities component creates a BrowserType object that
determines the type, capabilities and version number of a visitor's browser.When a browser connects to a server, a User Agent header is also sent to the server.This header contains information about the browser.The BrowserType object compares the information in the header with information in afile on the server called "Browscap.ini".If there is a match between the browser type and version number in the header and theinformation in the "Browsercap.ini" file, the BrowserType object can be used to list theproperties of the matching browser. If there is no match for the browser type andversion number in the Browscap.ini file, it will set every property to "UNKNOWN".
Syntax
ASP Browser Capabilities Example
The example below creates a BrowserType object in an ASP file, and displays some ofthe capabilities of your browser:
Example
Client OSWeb BrowserBrowser version
23
http://www.w3schools.com/ASP/asp_adrotator.asphttp://www.w3schools.com/ASP/asp_contentlinking.asphttp://www.w3schools.com/ASP/asp_adrotator.asphttp://www.w3schools.com/ASP/asp_contentlinking.asp -
8/3/2019 Cuadernillo ASP
24/35
Frame support?Table support?Sound support?
Cookies support?VBScript support?JavaScript support?
Output:
Client OS WinNT
Web Browser IEBrowser version 5.0
Frame support? True
Table support? True
Sound support? True
Cookies support? True
VBScript support? True
JavaScript support? True
The Browscap.ini File
The "Browsercap.ini" file is used to declare properties and to set default valuesfor browsers.This section is not a tutorial on how to maintain "Browsercap.ini" files, it onlyshows you the basics; so you get an idea what a "Browsercap.ini" file is allabout.The "Browsercap.ini" file can contain the following:[;comments][HTTPUserAgentHeader][parent=browserDefinition][property1=value1]
[propertyN=valueN][Default Browser Capability Settings][defaultProperty1=defaultValue1][defaultPropertyN=defaultValueN]
Parameter Description
comments Optional. Any line that starts with a semicolon areignored by the BrowserType object
HTTPUserAgentHeaderOptional. Specifies the HTTP User Agent header toassociate with the browser-property value statementsspecified in propertyN. Wildcard characters are allowed
browserDefinition Optional. Specifies the HTTP User Agent header-stringof a browser to use as the parent browser. The currentbrowser's definition will inherit all of the property valuesdeclared in the parent browser's definition
propertyN Optional. Specifies the browser properties. Thefollowing table lists some possible properties:
ActiveXControls - Support ActiveX controls?
Backgroundsounds - Support backgroundsounds?
Cdf - Support Channel Definition Format forWebcasting?
Tables - Support tables?
Cookies - Support cookies?
Frames - Support frames?
Javaapplets - Support Java applets?
Javascript - Supports JScript?
Vbscript - Supports VBScript?
Browser - Specifies the name of the browser
Beta - Is the browser beta software? Platform - Specifies the platform that the
browser runs on
Version - Specifies the version number of thebrowser
valueN Optional. Specifies the value of propertyN. Can be astring, an integer (prefix with #), or a Boolean value
defaultPropertyN Optional. Specifies the name of the browser property towhich to assign a default value if none of the definedHTTPUserAgentHeader values match the HTTP User
24
-
8/3/2019 Cuadernillo ASP
25/35
Agent header sent by the browser
defaultValueN Optional. Specifies the value of defaultPropertyN. Canbe a string, an integer (prefix with #), or a Boolean value
A "Browsercap.ini" file might look something like this:;IE 5.0[IE 5.0]browser=IE
Version=5.0majorver=#5minorver=#0frames=TRUEtables=TRUEcookies=TRUEbackgroundsounds=TRUEvbscript=TRUEjavascript=TRUEjavaapplets=TRUEActiveXControls=TRUEbeta=False
;DEFAULT BROWSER[*]browser=Defaultframes=FALSEtables=TRUEcookies=FALSEbackgroundsounds=FALSEvbscript=FALSEjavascript=FALSE
ASP Content Linking Component
ASP Content Linking Component
The ASP Content Linking component is used to create a quick and easynavigation system!The Content Linking component returns a Nextlink object that is used to hold alist of Web pages to be navigated.
Syntax
ASP Content Linking Example
First we create a text file - "links.txt":asp_intro.asp ASP Introasp_syntax.asp ASP Syntaxasp_variables.asp ASP Variablesasp_procedures.asp ASP ProceduresThe text file above contains the pages to be navigated. The pages must be listed in thesame order you want them to be displayed, and it must also contain a description foreach file name (use the tab key to separate file name from description).Note: If you want to add a page, or change the order of the pages in the list; you onlyhave to modify the text file! The navigation will automatically be corrected!Then we create an include file, "nlcode.inc". The .inc file creates a NextLink object tonavigate between the pages listed in "links.txt"."nlcode.inc":1) then
Response.Write("Previous Page")
end ifResponse.Write("Next Page")%>In each of the .asp pages listed in the text file "links.txt", put one line of code: . This line will include the code in "nlcode.inc" on everypage listed in "links.txt" and the navigation will work.
ASP Content Linking Component's Methods
Method Description Example
GetListCount Returns thenumber ofitems listedin theContentLinking Listfile
25
-
8/3/2019 Cuadernillo ASP
26/35
Output:
There are 4 items in the list
GetListIndex Returns theindexnumber of
the currentitem in theContentLinking Listfile. Theindexnumber ofthe firstitem is 1. 0is returnedif thecurrent page
is not in theContentLinking Listfile
Output:
Item number 3
GetNextDescription Returns thetextdescriptionof the nextitem listedin theContentLinking List
file. If thecurrent pageis not foundin the listfile itreturns thetextdescriptionof the lastpage on thelist
Next description is: ASP Variables
GetNextURL Returns the
Next URL is: asp_variables.asp
GetNthDescription Returns thedescriptionof the Nthpage listedin theContentLinking Listfile
Third description is: ASP Variables
GetNthURL Returns theURL of theNth pagelisted in theContentLinking List
file
Third URL is: asp_variables.asp
GetPreviousDescriptionReturns thetextdescriptionof thepreviousitem listedin the
-
8/3/2019 Cuadernillo ASP
27/35
ContentLinking Listfile. If thecurrent pageis not foundin the listfile itreturns the
textdescriptionof the firstpage on thelist
Response.Write(c)%>
Previous description is: ASP Variables
GetPreviousURL Returns theURL of thepreviousitem listedin theContentLinking Listfile. If thecurrent pageis not foundin the listfile itreturns theURL of thefirst page onthe list
Previous URL is: asp_variables.asp
ASP Content RotatorComponent (ASP 3.0)
ASP Content Rotator Component
The ASP Content Rotator component creates a ContentRotator object thatdisplays a different content string each time a visitor enters or refreshes a page.A text file, called the Content Schedule File, includes the information about thecontent strings.The content strings can contain HTML tags so you can display any type ofcontent that HTML can represent: text, images, colors, or hyperlinks.
Syntax
ASP Content Rotator Example
The following example displays a different content each time a visitor views the Webpage.First, create a text file named "textads.txt" and place it in a subfolder called "text"."textads.txt":%% #3This is a great day!!
%% #3
%% #4Visit W3Schools.comNotice the #number at the beginning of each content string. This number is an optionalparameter that indicates the relative weight of the HTML content string. In the text fileabove, the Content Rotator will display the first and second content string three-tenthof the time, and the third string four-tenths of the time.Then, create an ASP file, and insert the following code:
Example
ASP Content Rotator Component's Methods
Method DescriptionExample
ChooseContentGets anddisplays acontent
-
8/3/2019 Cuadernillo ASP
28/35
string cr=Server.CreateObject("MSWC.ContentRotator")response.write(cr.ChooseContent("text/textads.txt"))%>
Output:
GetAllContent Retrievesand displaysall of thecontentstrings inthe text file
Output:
This is a great day!!
Visit W3Schools.com
AJAX Introduction
AJAX is about updating parts of a web page, without reloading the whole page.
What is AJAX?
AJAX = Asynchronous JavaScript and XML.AJAX is a technique for creating fast and dynamic web pages.AJAX allows web pages to be updated asynchronously by exchanging smallamounts of data with the server behind the scenes. This means that it is possibleto update parts of a web page, without reloading the whole page.Classic web pages, (which do not use AJAX) must reload the entire page if thecontent should change.Examples of applications using AJAX: Google Maps, Gmail, Youtube, andFacebook tabs.
How AJAX Works
AJAX is Based on Internet Standards
AJAX is based on internet standards, and uses a combination of:
XMLHttpRequest object (to exchange data asynchronously with a server) JavaScript/DOM (to display/interact with the information)
CSS (to style the data)
XML (often used as the format for transferring data)
AJAX applications are browser- and platform-independent!
Google Suggest
AJAX was made popular in 2005 by Google, with Google Suggest.Google Suggestis using AJAX to create a very dynamic web interface: When you starttyping in Google's search box, a JavaScript sends the letters off to a server and the
server returns a list of suggestions.Start Using AJAX Today
In our ASP tutorial, we will demonstrate how AJAX can update parts of a web page,without reloading the whole page. The server script will be written in ASP.If you want to learn more about AJAX, visit ourAJAX tutorial.
ASP - AJAX and ASP
Previous Next Chapter
AJAX is used to create more interactive applications.
28
http://www.w3schools.com/http://www.google.com/http://www.google.com/http://www.w3schools.com/ajax/default.asphttp://www.w3schools.com/ajax/default.asphttp://www.w3schools.com/ajax/default.asphttp://www.w3schools.com/ASP/asp_ajax_intro.asphttp://www.w3schools.com/ASP/asp_ajax_database.asphttp://www.w3schools.com/http://www.google.com/http://www.w3schools.com/ajax/default.asphttp://www.w3schools.com/ASP/asp_ajax_intro.asphttp://www.w3schools.com/ASP/asp_ajax_database.asp -
8/3/2019 Cuadernillo ASP
29/35
AJAX ASP Example
The following example will demonstrate how a web page can communicate witha web server while a user type characters in an input field:
Example
Start typing a name in the input field below:
First name:
Suggestions:
Example Explained - The HTML Page
When a user types a character in the input field above, the function"showHint()" is executed. The function is triggered by the "onkeyup" event:function showHint(str)
{if (str.length==0){document.getElementById("txtHint").innerHTML="";return;}
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}
else{// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}xmlhttp.onreadystatechange=function()
{if (xmlhttp.readyState==4 && xmlhttp.status==200){document.getElementById("txtHint").innerHTML=xmlhttp.responseText;}
}
xmlhttp.open("GET","gethint.asp?q="+str,true);xmlhttp.send();}
-
8/3/2019 Cuadernillo ASP
30/35
'Fill up array with namesa(1)="Anna"a(2)="Brittany"a(3)="Cinderella"a(4)="Diana"a(5)="Eva"a(6)="Fiona"a(7)="Gunda"
a(8)="Hege"a(9)="Inga"a(10)="Johanna"a(11)="Kitty"a(12)="Linda"a(13)="Nina"a(14)="Ophelia"a(15)="Petunia"a(16)="Amanda"a(17)="Raquel"a(18)="Cindy"a(19)="Doris"
a(20)="Eve"a(21)="Evita"a(22)="Sunniva"a(23)="Tove"a(24)="Unni"a(25)="Violet"a(26)="Liza"a(27)="Elizabeth"a(28)="Ellen"a(29)="Wenche"a(30)="Vicky"
'get the q parameter from URLq=ucase(request.querystring("q"))
'lookup all hints from array if length of q>0if len(q)>0 then
hint=""for i=1 to 30if q=ucase(mid(a(i),1,len(q))) then
if hint="" thenhint=a(i)
elsehint=hint & " , " & a(i)
end ifend if
nextend if
'Output "no suggestion" if no hint were found'or output the correct valuesif hint="" then
response.write("no suggestion")else
response.write(hint)end if%>Explanation: If there is any text sent from the JavaScript (strlen($q) > 0), the followinghappens:
1. Find a name matching the characters sent from the JavaScript2. If no match were found, set the response string to "no suggestion"3. If one or more matching names were found, set the response string to all these
names
4. The response is sent to the "txtHint" placeholder
AJAX Database Example
AJAX can be used for interactive communication with a database.
AJAX Database Example
The following example will demonstrate how a web page can fetch information from adatabase with AJAX:
Example
Customer info will be listed here...
Example Explained - The HTML Page
30
-
8/3/2019 Cuadernillo ASP
31/35
When a user selects a customer in the dropdown list above, a function called"showCustomer()" is executed. The function is triggered by the "onchange"event:function showCustomer(str){
if (str==""){document.getElementById("txtHint").innerHTML="";return;}
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}
else{// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}xmlhttp.onreadystatechange=function()
{if (xmlhttp.readyState==4 && xmlhttp.status==200){document.getElementById("txtHint").innerHTML=xmlhttp.responseText;}
}xmlhttp.open("GET","getcustomer.asp?q="+str,true);xmlhttp.send();}
31
-
8/3/2019 Cuadernillo ASP
32/35
ASP Quick Reference
ASP Quick Reference from W3Schools. Print it, and fold it in your pocket.
Basic Syntax
ASP scripts are surrounded by . To write some output to a browser:The default language in ASP is VBScript. To use another scripting language,insert a language specification at the top of the ASP page:
Forms and User Input
Request.QueryString is used to collect values in a form with method="get".Information sent from a form with the GET method is visible to everyone (it willbe displayed in the browser's address bar) and has limits on the amount ofinformation to send.Request.Form is used to collect values in a form with method="post".Information sent from a form with the POST method is invisible to others andhas no limits on the amount of information to send.
ASP Cookies
A cookie is often used to identify a user. A cookie is a small file that the server embedson the user's computer. Each time the same computer requests for a page with abrowser, it will send the cookie too.The Response.Cookies command is used to create cookies:
Note: The Response.Cookies command must appear BEFORE the tag!The "Request.Cookies" command is used to retrieve a cookie value:
Including Files
You can insert the content of one ASP file into another ASP file before the serverexecutes it, with the #include directive. The #include directive is used to createfunctions, headers, footers, or elements that will be reused on multiple pagesSyntax:
orUse the virtual keyword to indicate a path beginning with a virtual directory. If a filenamed "header.inc" resides in a virtual directory named /html, the following line wouldinsert the contents of "header.inc":Use the file keyword to indicate a relative path. A relative path begins with thedirectory that contains the including file. If you have a file in the html directory, andthe file "header.inc" resides in html\headers, the following line would insert"header.inc" in your file:
Use the file keyword with the syntax (..\) to include a file from a higher-level directory.
Global.asa
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.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 can contain only the following:
Application events
Session events
32
-
8/3/2019 Cuadernillo ASP
33/35
declarations
TypeLibrary declarations
the #include directive
Application and Session Events
In Global.asa you can tell the application and session objects what to do whenthe application/session starts and what to do when the application/session ends.The code for this is placed in event handlers. Note: We do not use ,to insert scripts in the Global.asa file, we have to put the subroutines inside theHTML tag:sub Application_OnStart
' some codeend subsub Application_OnEnd
' some codeend subsub Session_OnStart
' some codeend subsub Session_OnEnd
' some codeend sub Declarations
It is also possible to create objects with session or application scope inGlobal.asa by using the tag. Note: The tag should be outsidethe tag!Syntax:.......
TypeLibrary Declarations
A TypeLibrary is a container for the contents of a DLL file corresponding to aCOM object. By including a call to the TypeLibrary in the Global.asa file, theconstants of the COM object can be accessed, and errors can be better reportedby the ASP code. If your Web application relies on COM objects that havedeclared data types in type libraries, you can declare the type libraries inGlobal.asa.Syntax:
The Session Object
The Session object is used to store information about, or change settings for a usersession. Variables stored in the Session object hold information about one single user,and are available to all pages in one application.
Collections
Contents - Holds every item added to the session with script commands
StaticObjects - Holds every object added to the session with the tag,and a given session
Contents.Remove( item/index) - Deletes an item from the Contents collection
Contents.RemoveAll() - Deletes every item from the Contents collection
Properties
CodePage - Sets the code page that will be used to display dynamic content
LCID - Sets the locale identifier that will be used to display dynamic content
SessionID - Returns the session id
Timeout - Sets the timeout for the session
Method
Abandon - Kills every object in a session object
Application Object
A group of ASP files that work together to perform some purpose is called an
application. The Application object in ASP is used to tie these files together. All usersshare one Application object. The Application object should hold information that willbe used by many pages in the application (like database connection information).Collections
Contents - Holds every item added to the application with script commands
StaticObjects - Holds every object added to the application with the tag
Contents.Remove - Deletes an item from a collection
Contents.RemoveAll - Deletes every item from a collection
Methods
33
-
8/3/2019 Cuadernillo ASP
34/35
Lock - Prevents a user from changing the application object properties
Unlock - Allows a user to change the application object properties
The Response Object
The Response Object is used to send output to the user from the server.Collection
Cookies(name) - Sets a cookie value. If the cookie does not exist, it willbe created, and take the value that is specified
Properties
Buffer - Whether to buffer the output or not. When the output isbuffered, the server will hold back the response until all of the serverscripts have been processed, or until the script calls the Flush or Endmethod. If this property is set, it should be before the tag in theASP file
CacheControl - Sets whether proxy servers can cache the output or not.
When set to Public, the output can be cached by a proxy server Charset(charset_name) - Sets the name of the character