Server-Side Scripting

The web server is not only responsible for processing HTML tags but also the ASP scripts. The ASP engine, installed on the web server, is responsible for processing ASP scripts. Because the browser can only display HTML compatible text, it is the responsibility of ASP engine to process the ASP scripts and send the results back as HTML text to the client. In other words, the Web server sends HTML text, part of which may be the result of the ASP scripts.

You might be thinking how the Web server can determine whether to call ASP engine or not. You should recall from your HTML experience that HTML files have the .html or .htm extension. Similarly, .asp extension is used for ASP scripts. An .asp file extension indicates to the Web server to call the ASP engine. HTML tags inside an ASP file are processed by the ASP engine; however, an html file (meaning a file that ends with .htm or .html) containing ASP code won't run the ASP code!

Once the Web server sends the results to the client, it is the client's browser responsibility to display HTML text. Again, the client's browser only receives HTML text. This can be confirmed, for an asp file, by viewing the source code in the browser window. Note server-side scripts are processed before a page is downloaded on a browser, and client-side scripts are processed after a page has been downloaded. When we are writing ASP scripts, we are writing pages for server-side processing. Table 1 summarizes the differences between client and server side scripting.

Table 1 - Summary of Client-side and Server-side Scripting
Client-side Scripting
  • It is the client's responsibility to process client-side scripts. The client-side scripts are not processed by the Web-server.
  • Client-side scripts are processed after a Web page has been downloaded onto the browser.
  • Client-side scripting is useful for validating user's input.
Server-side Scripting
  • A web server is responsible for processing ASP scripts and returning output to the client.
  • The server-side scripting is done before a page is downloaded on the browser.
  • ASP scripts is a server-side technology.

The following provides a breif summary of the steps involved in processing ASP files:

  1. A web browser requests an ASP file
  2. The web server recives the request and loads the ASP file.
  3. The server executes the code inside the ASP file. Any output from this processed ASP code is sent to the browser in HTML format, along with any other HTML content.

Because Active Server Pages is a server-side technology, it offers number of notable advantages:

  • ASP code remains on the server. Because ASP code does not leave the server, the user does not learn about how the page is built. This provides a measure of security of your ASP code and other files used in conjunction with your ASP code.
  • ASP is a stable and matured technology. Microsoft, third-party vendors, and developers, are some of the players providing support (i.e., tools, components, scripts, discussion boards, etc.) for the ASP technology.
  • An ASP file can use databses or other files available to the web server to produce the desired output.