![]() |
![]() |
www.tamertolba.4t.com |
|||||||||||||||||||
|
Chapter 1 Introduction
Active Server Pages is an open, compile-free application environment in which you can combine HTML, scripts, and reusable ActiveX server components to create dynamic and powerful Web-based business solutions. Active Server Pages enables server side scripting for IIS with native support for both VBScript and Jscript. ( Microsoft Internet Information Server Web site ) That's what they say, at least. When you read that paragraph, you want to know what this means to you as a developer, whether the Active Server Pages (ASP) technology is easy to use, and, most of all, how it works.
Static Web pages are a thing of the past and dynamic content is here to stay. As the Internet becomes increasingly congested with information, sites must be up-to-date to be successful. People won't keep coming back to a Web site if the "Headlines of the day" start becoming the headlines of the month. Only by modifying and adding information on a daily basis can a site stay successful and keep attracting visitors. The time and expense involved to do this can be overwhelming and is not feasible for many individuals and companies.
The solution is not to hire more Web page editors, it is to design and build sites that keep themselves current. This doesn't mean artificial intelligence, just the application of client/server knowledge to the Internet. Web sites that automatically update themselves are not new, but how you create one is changing all the time. One of the newest, and most popular, technologies is Active Server Pages (ASP). By using ASP, you can create Web sites that do almost anything and do it quickly.
1.1- Static & Dynamic web sites:: Whether you know it or not, you probably have already seen examples of both static and dynamic Web sites. Static content, or a static Web site, is made up of pages whose content does not change on its own. Any Web page can be changed by its owner through an editor, but that doesn't make it dynamic. Consider the example of billboards. Like Web pages, billboards can be either dynamic or static. Most billboards advertise such things as the distance to the advertiser's next fast food restaurant or gas station. These billboards have static content; it doesn't change unless someone manually changes it. On the other hand, some billboards display such things as the current time and temperature. This is dynamic content; it changes as the information displayed changes. Obviously, some types of billboards are more suited for static content than dynamic content. The distance to the fast food restaurant isn't likely to change, so a dynamic electronic sign wouldn't be very useful. The reverse is also true--a painted sign displaying the time and temperature would always be wrong. It is usually clear from the content whether a dynamic or static billboard is called for.
Note : Dynamic HTML: It is important not to get this confused with Dynamic HTML, which is another important technology from Microsoft that is being released as part of its latest Internet browser (Internet Explorer 4.0).Whereas Dynamic Web pages are called dynamic because their content may change every time you visit the site (reload the page), Dynamic HTML is a technology that enables Web pages to change appearance on the client side(without reloading). For example, text that changes as you move your mouse over different sections, or displaying database records that you can browse through without the page having to reload.
1.2- When to Build Dynamic Sites:Two key questions determine the need for dynamic content: 1-Does the information that the site displays change often? 2-Is that information available (through a database, live feed, and so forth) to the Web server? For example, a site that displays stock price information must be dynamic. The information changes every second and those changes need to be fed electronically to the Web server. Conversely, a site that displays the names of the 50 states of the U.S. probably doesn't need to be dynamic. While the states' names are available in electronic form, they don't change and therefore such a site doesn't require dynamic features. It is important to justify the extra time or money required to build a dynamic site. The advantages of a dynamic site are not immediately obvious--until a change needs to be made. For example, suppose a course currently labeled as NT 3.51 Administration needs to be called NT 4.0 Administration. Making this change in the static site involves the Web designer (or someone else with Web page skills) coming in and changing the listings page, the schedule page, and perhaps a few other pages where the course names are being used in such things as drop-down lists. This change could take an hour or more, plus the time for the Web designer to arrive. Even if the Web builder is available the next day, that is one entire day with incorrect information being shown to potential clients of the company. In contrast, to make this change in the dynamic site, the training administrator (or another company employee) opens a standard database-editing program (custom made through MS Access or similar program) and changes the few characters that need editing. Instantly, the information displayed on every part of the Web site is correct. With that one change, the company has started to recoup the increased cost of building a dynamic Web site. Likewise, if such changes are required often (as is typical), the cost benefit of the dynamic site grows quickly. The entire investment eventually will be recouped and the Web site will begin to save the company money almost immediately.
1.3- How to Build Dynamic Sites:Determining that you need a dynamic site isn't the end of the process; now you have to build it, and this isn't necessarily easy. To create a dynamic site, you need to pick a technology to use. The technology most commonly used for this purpose is CGI (Common Gateway Interface). This generic term describes programs that interface with Web servers and respond to requests by sending back Web pages, using a combination of parameters and back-end data to determine its content. These applications can do almost anything you want with a Web site, and can be written in several languages, including C ,Visual Basic and Perl--so why would you use anything else? CGI is difficult; it involves the creation of low-level programs in languages that lack most of the features of new development tools (like Visual Basic). Many of the functions required to generate the Web page, such as database access, are not provided to the programmer; you would have to build those functions your self. Most CGI applications do not support ODBC (Open Data Base Connectivity), DAO (Data Access Objects), or many other features programmers have become used to.In addition, CGI applications are inefficient. Each concurrent request against a CGI application creates another process on the server, resulting in poor performance and higher memory usage.In general, CGI is out of date; the concept is good, but it is not up to the task. While ASP runs as a service of the Web server and is optimized for multiple threads and multiple users. This means that it's fast, and it's easy to implement. If you use ASP, you can separate the design of your Web page from the details of programming access to databases and applications. The need for dynamic Web sites still exists and it is steadily increasing--so what should be used to create them?
1.4- Active Server Pages:Programmers want all the functionality of existing CGI applications, combined with the ease of use and support for language standards such as Visual Basic. Programmers want Active Server Pages (ASP). ASP is the perfect replacement for CGI, and it is still a handy TLA (three-letter acronym). It is built on the same standards programmers have become used to, allowing the use of COM objects directly. You can connect to the same middle- or back-end objects as your client VB applications do, and do it almost exactly the same way. It uses VBScript (or any other ActiveX Scripting Language, such as JavaScript), thus allowing programmers to transfer their knowledge of Visual Basic directly into this new environment.
1.5- How ASP Works:Well, now that you know that ASP is wonderful, let's discuss why. To understand what ASP is, it is important to discuss first what happens when a Web page is viewed. The first step in the viewing process is the browser request. When the user types an URL (uniform resource locator) into their Web browser, or clicks an existing hyperlink that points to that URL, the browser initiates a request. For the purposes of this example, let's assume the user typed in the following URL (http://www.microsoft.com/ie/default.htm ) The browser first looks at the address to determine which server to send the request to (in this example, this would be www.microsoft.com) and what to ask for (the document /ie/default.htm). This request is sent to the server by using HTTP (Hypertext Transfer Protocol), a common language that both the browser and the server understand. The second step starts when the server gets involved. When the server receives the request, it begins to process it. In the case of a simple Web page, this processing isn't very involved; the content of the appropriate file on the server is read from the server's hard disk and sent back to the browser, unchanged. The final part of the cycle occurs when the requesting browser receives the Web server's response. In this case, the response consists of the text contained in the requested file. The browser uses the HTML tags contained in the response to determine how to display the page to the user. In the case of Active Server Pages, the server side of the request-response process becomes a little different. Once again, the browser is directed to an URL, and it creates a request (as above, but the URL would end in a .asp instead of .htm (http://www.microsoft.com/ie/default.asp)). The Web server is contacted and the request is sent. Up until this point, nothing occurs any differently then for a regular HTML page; the difference occurs when the server becomes involved.
1.6- Why is ASP called so?Active Server Pages (ASP). It's a boring name, but an Web development technology that's changing the way dynamic pages are developed. ASP is "active" because it enables Web pages to be programmatic; interpreted on the "server" and developed on a "page" basis.1.7- Browser Independence:Although there are common elements between ASP and other Internet technologies such as client-side scripting (VBScript) and ActiveX controls, there is also one important difference--ASP occurs completely on the server. What does this mean? if you include VBScript in your page,attached to a button click for instance, it won't work on a browser that doesn't supportVBScript. These are examples of client-side technologies, and they are browser dependent. ASP does not involve the browser. All of the code is executed on the server; the browser just receives standard HTML from the server and displays it. The fact that the HTML was generated is hidden from the client-side of the process. This makes ASP browser independent, an important feature that makes ASP perfect for the Internet, where you have no control over what type of browser people are using. Of course, it is still possible to use client-side scripting and ActiveX controls in the pages generated by ASP, if browser independence is not required 1.8- ASP Features:ASPs give Web page developers the following advantages over standard Web application development: 1-ASPs combine HTML with script in the same file for better application flow. 2-Because the scripts are processed on the server, you don't have to worry about the browser's script capabilities. 3-ASPs support VBScript and JScript. 4-ASPs operate on the Advanced Intrinsic Object Model. 5-ASPs provide state management. 6-ASPs enable Visual Basic developers to perform functions that previously required CGI or ISAPI programming. 7-ASPs provide easy access to databases via ADO. 8-ASPs integrate ActiveX server components.
So what are the drawbacks of using ASPs? Well, we haven't encountered many.
Before going further into ASP, it is important to understand what makes up an ASP application. An ASP application consists of a virtual directory on a Web server and all the files and directories that exist in the virtual directory. Each ASP application can contain a single file named Global.asa, which must be stored in the application root directory. The Global.asa file contains several object events (discussed later in this documentation) that can be used to initialize the application or user sessions. The application's virtual directory must have read and execute privileges on the IIS. |
||||||||||||||||||||