Introduction

Textbook Chapter 7: Introduction to Server-side Scripting:

Active Server Pages (ASP) - with PHP notes

Check out ASP and PHP EXAMPLES - SIDE BY SIDE and check out the http://webcheatsheet.com/php/.

Download ASP.NET Web Matrix at http://www.asp.net/webmatrix/. ASP.NET Web Matrix is a community-supported, easy-to-use WYSIWYG application development tool for ASP.NET. New features include: Access database support, J# support, design time enhancements including improved table editing and user-control rendering, many bug fixes, and much more! Best of all? It's absolutely free!

Great language reference for VBScript from DevGuru.com at http://www.devguru.com/technologies/vbscript/home.

Up to this point, we've created client-side scripts using JavaScript and VBScript. Client-side scripts are interpreted by a scripting engine that is built into the browser. Client-side scripts use the objects built into the browser's Document Object Model.

In this chapter we'll take a look at how to create server-side applications using Active Server Pages (ASP) and PHP. You need to have access to a web server that supports ASP in order to work through the examples in this chapter. Both Personal Web Server (PWS) and Internet Information Server (IIS) support ASP and are available free from Microsoft. However, Personal Web Server only runs on Windows 9x. Windows 2000 has IIS built in. Also, Windows XP Professional edition has IIS. Windows XP Home Edition does not include IIS. In order to run your PHP scripts, you simply need any Web server with PHP installed. You can set up Apache (free, open source Web server that runs on Windows or Linux) or use IIS.

Our class web server supports ASP and PHP. You can upload your files to your account on our class web server and run all your scripts. Developers often set up a web server on their own computer so that they can quickly test and debug their scripts, without having to upload them to the server. If you want to set up your computer at home to operate as a web server running ASP for testing purposes, here's some information.

Information on how to obtain and set up an ASP compliant Web server such as Personal Web Server (PWS) can be found in the Before You Begin section of our textbook.

If you are running Windows 95 or Windows 98, install Personal Web Server. PWS ships with programs including Visual InterDev, FrontPage, Visual Studio and Windows 98. PWS allows programmers to preview their server-side scripts on their computer, without having to connect to the Internet. To install PWS, insert your Windows 98 CD, click START, then click RUN, then type d:\add-ons\pws\setup.exe and press ENTER. If your CD-ROM drive letter is different, substitute it for D.

If you are running Windows 2000 or Windows XP Professional, you've already got Internet Information Server on your computer. You may need to Add/Remove Windows components if it is not installed. Click on START, SETTINGS, CONTROL PANEL, then double-click ADD/REMOVE PROGRAMS, then click on ADD/REMOVE WINDOWS COMPONENTS.

UPDATE: With Windows 7, IIS 7.5 is available, but not installed by default. Here are the installation instructions: http://technet.microsoft.com/en-us/library/cc731911.aspx.

Once you've got PWS or IIS running, you can download and install the PHP Windows binaries at http://www.php.net/downloads.php or Search php.net for Windows binaries.

There are some issues with installing PWS on Windows ME. However, THIS LINK should provide some help in getting it to work.

If you are running Windows XP HOME Edition, and want to set up a Web server to test your scripts, Microsoft says you should buy the Professional edition (or here). However, http://www.15seconds.com provides a non-supported or tested solution (or here).

UPDATE: Looking for a Free, Open-Source, .NET Web Server? Check Cassini at ASP.NET. Here's what 4GuysFromRolla have to say about Cassini. Also, check out the ASP.NET Web Matrix Project.

Keep in mind that you do not HAVE to set up a web server on your computer at home or work. You can FTP your scripts to our class server to run them. Setting up a web server on your home or work computer will allow you to test and debug your scripts locally, saving the time of having to upload them to our class server first.

Introduction to ASP & PHP

HTML is a markup language. Browsers interpret HTML tags. The <SCRIPT> tag tells the browser to process the client-side script using the scripting engine that is built into the browser.

An Active Server Page (ASP) or a PHP page is a Web page that contains server-side script. ASP and PHP pages may also contain HTML and client-side scripts, but only the server-side scripts are executed on the server. When the server has finished processing the server-side script, it sends the HTML and client-side script to the browser to be interpreted on the client. ASP pages carry the file extension .asp, as opposed to .htm or .html. PHP pages carry the file extension .php, as opposed to .htm or .html. Since the server-side script is processed on the server, the source code is never accessible to the visitor. Therefore, ASP can be used to implement security rules within a Web site. Because server-side scripts are not executed within a browser, they cannot access the browser's Document Object Model (DOM). However, they can access the ASP Model, which includes many built-in objects that allow you to create more dynamic and interactive Web pages.

When the Web server recognizes the .asp file extension, it sends the request to the ASP engine. The ASP engine is actually a dynamic-link library called asp.dll, which is installed on the Web server. When the Web server recognizes the .php extension, it sends the request to the PHP engine. The PHP engine is actually a dynamic-link library called php4ts.dll, which is installed on the Web server.

After the request has been passed to the ASP engine, the ASP engine executes scripts in the Global Application File. The Global Application File is named global.asa and resides in the root directory of the web application. Then, SSI files are assembled to be placed in the Web page. Next, the ASP engine sends scripts to the scripting engine to be processed. Server-side scripts are interpreted, not compiled like C or VB. However, ASP.NET is no longer an interpreted language, rather it is a compiled language - compiled common language code executing on the server. Finally, the Web server sends the file to the browser using HTTP. PHP operates the same way to the programmer and users.

Server-side scripts are browser independent because server-side scripts are never sent to the browser; they are always executed on the Web server.

Built-in Objects in the ASP Object Model

Just as we can integrate client-side scripts with objects built into the browser's Document Object Model, we can integrate our server-side scripts with the built-in objects from the ASP Object Model. PHP uses functions to accomplish the same thing.

Third Party and Custom Objects

There are many companies developing third party objects that can be access from your ASP code. You can also create your own custom objects in Visual Basic and other languages. These objects must be installed and registered on the Web server. Many custom PHP functions can be found on the Internet for download.