Active Server Pages

 

Emerging Technologies
Prepared for Cliff Layton

Michael D. Donahoe
July 11, 2002

 

 

 

Introduction

 

Active Server Pages or ASP is a specification designed by Mircosoft for a dynamically created web page with a .asp extension that utilizes Active X scripting.  Most ASP pages are written using VB script a simpler version of Visual Basic code, but other languages have recently been incorporated such as Jscript – similar to Javascript, and more traditional languages such as C++, Perl, and CGI..  When a browser such as Internet Explorer or Netscape Navigator requests an ASP page the Web server generates a page with HTML code and sends it back to the user’s browser.  This concept is commonly known as server-side scripting where the script is executed on the server side rather than the client or user’s side.

ASP is used in various ways to create dynamic and useful web sites and web applications. Visual effects can be added to a web page to help enhance the visitor’s experience by use of forms, changing of backgrounds, etc. These pages can be used to add a personal touch to a page by “remembering” the visitors name with the use of a cookie or by utilizing the most powerful tool of ASP to interface with a database.  By connecting to a database user authentication can be performed which can tie together specific information in the database that relates to the user.

The example shown above is an ASP page that I wrote for our Quality Department at work.  As you can see when the page is pulled up after I’ve logged in with a user name and password, it addresses me with a specialized greeting.  This particular page is connected to a MS Access database which when I entered my user name and password, it stored that information into a cookie and then did a lookup in the database for a user name that matched the value in the cookie.  It then cross referenced that information to what my actual first name was and returned that information back to the web page.  Thus you’ll see “Welcome to the IQO Database” and then my first name, “Michael”.  The page then goes further to access records in the database that apply to me.  It searches for audit requests for me to do, then shows me the requests that I have accepted and still need to perform.  This database is all web interfaced to the MS Access database.  Through the use of ASP users are able to read, write, and view information in an HTML format to the database.  It literally gives the complete power of a database to an HTML format.  Also, it greatly enhances capabilities of the database.  Whereas there are a limited number of users that can connect to a MS Access database at a single time, it isn’t the case by interfacing with ASP pages.  Since the users are interfacing the MS Access database through the Web, this database can support virtually over 1,000 users at any given time.  This simply because the ASP pages request the info one time, which takes milliseconds to download, then the ASP page does all the processing of the information before sending it to the users’ browser.  The database itself does very little processing at all other than initially running the requested query. 

History

 

Active Server Pages 1.0 was released in 1996 to be used in conjunction with IIS (Internet Information Server) on Windows NT web servers.  Before the invention of ASP there was CGI/Perl and PerlScript that processed information from and to web pages from the server side.  A CGI application could only handle one CGI user at a time.  If 20 people were to fill out and send information from a web forms on 20 separate computers, then 20 copies of the CGI application had to be ran on the server.  This slowed down the server quite considerably.  Server APIs or Application Programming Interfaces were then developed to allow multiple users to a single web application. 

Microsoft’s version of APIs are ISAPI, or Internet Server Application Programming Interface.  ISAPI is more efficient than the traditional CGI interfaces.  CGI, however, is very widespread, particularly on UNIX servers.  Developments have recently been made to allow CGI to work in conjunction with ASP pages as well.  Creating web sites with ISAPI was very time consuming and was very difficult to program, this made development very expensive to maintain.  Active Server Pages then evolved which are easy to learn and are just as efficient as ISAPI.

 

 

 

Hypertext Markup Language

 

In order to understand ASP, some brief knowledge of how a web page is constructed must be known. Most web pages are written in HTML (hypertext markup language), which is processed by your web browser. The following is a very simple web page.

To the right you will see a very simple web page written in HTML that contains a picture, text, and a link.  If we were to view the source code for the web page by right-clicking on the page and selecting 'view source' from the pop-up menu you would see the HTML code displayed that is downloaded to the web browser.  The web browser displays the web page based upon the following code or tags.


<html>
<head>
<title>
My HTML Homepage</title>
</head>
<body>
<p><img   src=
"bs01316_.wmf" width="102" height="186"></p>
<p>
To see my real homepage <a href="http://www.mdonahoe.com">&lt;click here&gt;</a></p>
</body>
</html>

 

This example of an HTML page is very simple example of a common web page.  When the address of the web page is typed into the address bar, the page html code is downloaded directly from the web server and then executed by the client-side web browser.

 

ASP in Action

 

The appearance of an Active Server Page is very similar to a standard HTML page.  In fact, to the Web browser that receives the web page, there is no difference in the look; the difference is what can be obtained in the content.  If the user was to view the source of an ASP page all they would see is the HTML code of the page combined with the HTML code written by the server-side scripts that exist in the page on the server.  In other words, the user only can view the results of the scripts.  If a user were able to see the ASP page on the server, you would be able to see embedded scripts within the HTML code of the web page that produces the information seen by the user.

Server-side scripts look a great deal like HTML tags.  However, instead of tags starting and ending with lesser-than ( < ) and greater-than ( > ) brackets, they start with <% and end with %>.  These are called opening and closing tags that tell the server to perform the function that’s inside of those tags before sending to the user.  These tags and the scripts can be inserted anywhere within a Web page, even inside of HTML tags. 

 

It is important to understand that when using ASP to process information to a web page that the charachteristics of what is displayed to the user are that of the server.  In the example following I have created a web page that displays the day of the week, if a person were to create an ASP that displayed the current time, it would display the server’s time and not the user’s time.  This could be confusing to some users depending on the use that are in different time zones than where the server is located.

To the right is an example of the same Web page that we used before only instead we've added a server-side script within the HTML code to print the day of the week. The following is the code for the ASP page:

<html>
<head>
<title>
My ASP Homepage</title>
</head>
<body>
<p>
Welcome to my homepage.</p>

<p>Today is <% = WeekdayName(Weekday(Date)) %> </p>

<p><img border="0" src="../../../Inetpub/wwwroot/iqo/bs01316_.gif" width="102" height="186"></p>
<p>
To see my real homepage <a href="http://www.mdonahoe.com">&lt;click here&gt;</a></p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
</body>
</html>

 

This one line server-side script, written with VBscript takes the server's date, determines the weekday as 5, and then writes the weekday name of the fifth day of the week, which is Thursday.

If the client views the source of the ASP from his or her web browser the result will only show the results of the executed VBscript rather than the contents of the VBscript code.

<html
<head
<titleMy ASP Homepage</title
</head
<body
<pWelcome to my homepage.&nbsp; </p

<pToday is Thursday </p          
ß Result of executed script.

<p<img border="0" src="bs01316_.gif" width="102" height="186"</p
<pTo see my real homepage <a href="http://www.mdonahoe.com"&lt;click here&gt;</a</p
</body
</html

As seen above, rather than client being able to see the VBscript that computes the day of the week, only the result will be written, "Thursday" as if it were written directly into the HTML code.  Of course this is a very simplified example.  Generally, more complex code written in VBscript is utilized to interface with databases such as online banking, compiled customer feedback from online survey forms, full e-commerce websites that include purchasing, viewing based upon user preferences, etc.  

ASP.NET – The Latest Innovation in ASP Technology

 

ASP.NET is the latest version of ASP following ASP 3.0, sometimes currently referred to as ASP+.  It is currently supported on Windows 2000 and Windows XP with IIS installed..  However, just as ASP 3.0 had aftermarket versions produced that ran on Linux, MAC and other operating systems by such vendors as ChiliSoft, I would expect at a later date to see the same evolve with ASP.NET.  Some newer development tools for ASP.NET can be downloaded at http://www.asp.net, a branch off of the Microsoft Development website, or from http://www.asp101.com. 

Just as ASP utilized a .asp extension for the server to process it as a ASP page, pages designed with ASP.NET use a .aspx extension for the server to process them.  Where before there were a few languages being used to process ASP pages, now new languages have been created to run ASP.NET, most common are C# - a simpler version of C++, Visual Basic.NET – another and similar version of Visual Basic, and Jscript.NET – A JavaScript based language specifically designed for ASP.NET.  The ASP.NET pages can be written with a text editor such as notepad in the same way that ASP pages could be, but there are developer tools that are currently free such as the ones found at the webmatrix project found at http://www.asp.net that are windows based and offer many shortcuts in developing the pages by point and click.  The developing tools are not unlike the Visual Basic InterDev tools from before and can be pretty complicated for beginners but if you have some programming background ASP.NET will be easier and offers a lot of time-savers in its development. 

ASP.NET promises to provide unprecedented developer productivity with performance, reliability, and easier deployment.

Developer Productivity – This obtained by an easier programming model that uses far less amounts of code than was previously required with classic ASP.  This is done by using tools, and code that are already built-in.  It allows displaying data, user input validation, and uploading files to be much easier than ever before.  ASP.NET now has more flexibility with its programming language options.  Application features that used to be very difficult to implement, or required purchasing third party components can now be added by just a few lines of code using the >NET Framework.  These features are completely built in and offers over 4500 classes that use features such as XML, data access, file uploading, commonly used expressions, image generation, performance monitoring and logging, SMTP mail, and so on.

Improved Performance and Scalability – ASP.NET is much faster than classic ASP offering less tasking of the server to perform its functions.  It does so by using compiled execution it which the ASP.NET will automatically detect any changes to the page and dynamically compile the files as necessary rather than having to send information from a web page to be processed and then sent to another page for display.  Output caching allows a page to be executed just once and then it saves the information from the page in memory in addition to sending it to the user.  When another user requests the same page ASP.NET will serve the cached result from memory on the hard drive rather than have to process the script multiple times.  Output caching is also configurable and can cache just part of a result or the entire result.  A comparable test was ran using Sun’s Java Pet Store J2EE blueprint application against the same setup using ASP.NET implementation.  The ASP.NET implementation required 1/4th as many lines of code, was 28x faster, and supported 7.6x as many concurrent users as J2EE, with only 1/6th the amount of processor utilization.

Enhanced Reliability – ASP.NET will automatically detect and recover from errors such as deadlocks and memory leaks.  If a web application ties up a significant percentage of the server’s virtual memory due to a memory leak, ASP.NET will automatically create a copy of the ASP.NET worker process and direct all the new requests to the newly created process.  Once the old process has finished all pending requests, it is automatically disposed and the leaked memory is released freeing up the server’s resources.  No administrator intervention is required and no interruption of service will occur.

Easy Deployment – When a web application is created using ASP.NET similar  CLASS objects or COM object used for specific functionality on classic ASPs, it is not necessary to input them into the registry or adjust configuration settings in an XML file.  It merely needs to be present in the web servers root directory.  When objects are updated now, they can be copied over the existing DLL files and the server does not need rebooted, ASP.NET will detect the change and start using the newer copy.  Migration from classic ASP to ASP.NET is very simple.  Since both of them use separate scripting engines, they can both be ran on the same server and pages can be migrated one at a time until they are completed.

New Application Models – With ASP.NET developers can take advantage of XML web services that allow applications to communicate over the Internet, regardless of the Operating Systems.  It is also very easy to call on XML service with just a line of code, it isn’t necessary to have to have knowledge of XML, networking, or SOAP.  ASP.NET also has built in Mobile Controls that easily target cell phones, PDAs, and other mobile devices.  After writing an application there are converters that will automatically generate WAP/WML, HTML, or iMode as required by the requesting devices.

 

Conclusion

 

ASP and ASP.NET offer a great deal of benefits to web developers wanting to build tailor-made, and powerful web sites.  Many banks, e-commerce sites, database oriented websites, and colleges use ASP due to it’s flexibility, ease of programming and common security from the user.  However, throughout my research there were cons to the pro.  Because of the widespread use of IIS which is required for ASPs to run on, it makes it a larger, not easier, target for hackers.  Microsoft continually submits updates for IIS in order to try to counter and stay ahead of the hackers’ ploys. 

ASP.NET will certainly prove to be the next generation of web development available.  Microsoft has continually migrated towards XML platforms and making their operating systems more web friendly.  ASP.NET has offered another step in the coercion of platforms which will separate its web server platforms from other choices, for now.  Either way, it has provided a huge step for it’s competition to meet, and will drive competitors to be more innovative in their designs, thus only providing a huge benefit in web technology for the consumers.

 

 

References

 

Cox, Keith (1997, December) Active Server Pages (An introduction to web-based application development) <http://www.abiglime.com/webmaster/articles/asp/122297.htm>

Gunesh, Arun (2002) Active Server Pages <http://www.developer.be/index.cfm/fuseaction/tutorialDetail/GroupID/50/tutorialName/IntroductiontoASPNET.htm>

Burns, Joe, Phd. (2002) So you want ASP huh? <http://www.htmlgoodies.com/beyond/asp.html >

ZDNet (October 20, 2001) Server Side vs. Client Side Scripting <http://www.zdnetindia.com/help/howto/stories/34090.html>

Hitmill.com (July 23, 2002) ASP and the Internet<http://www.hitmill.com/programming/asp/asp_idex2.html>

Microsoft Corporation (2002) Why ASP.NET <http://www.asp.net/whitepaper/whyaspnet.aspx >

Peterson, John (2002) Microsoft ASP.NET Web Matrix Project – Version 0.5 <http://www.asp101.com/articles/john/aspnetmatrixb1/default.asp>