Legacy Guidance:This article preserves historical web development content. For modern .NET 8+ best practices, visit our Tutorials section.
Server-Side Processing in ASP
The key advantage of ASP is that your scripts run entirely on the server, protecting your intellectual property and shielding you from browser compatibility issues you had to account for with client-side code. Your server-side code gets processed completely, and only plain HTML—or whatever content you choose to generate—reaches the client.
How ASP Processing Works
When the web server receives a request for an .asp page, it invokes the ASP engine, which triggers the appropriate scripting language to execute your server-side code. The processing flow looks like this:
Basic ASP Page Structure
<%@ Language="VBScript" %>
<html>
<head>
<title>Sample ASP Page</title>
</head>
<body>
<%
' Server-side code runs here
Response.Write "Hello from the server!"
Dim currentTime
currentTime = Now()
Response.Write "<p>Server time: " & currentTime & "</p>"
%>
</body>
</html>
Language-Agnostic Architecture
One major benefit of ASP is that it's language-agnostic. You're not limited to Microsoft's standard scripting languages like VBScript. You can extend ASP with any scripting language that supports the ActiveX scripting model, giving you flexibility in choosing the right tool for your project.
Built-in ASP Objects
Since scripting languages don't inherently know how to work with web servers or send data to clients, ASP provides six built-in objects that handle request and response processing and help you create and manage web applications:
Application Object
Stores application-wide state information that's shared across all users. Use it for data that applies to your entire application:
Contains all information passed from the browser to the server. Use it to access form data, query strings, cookies, and server variables:
Request Object Example
<%
' Access form data
Dim userName
userName = Request.Form("username")
' Access query string
Dim pageId
pageId = Request.QueryString("id")
' Access cookies
Dim userPreference
userPreference = Request.Cookies("theme")
%>
Response Object
Writes HTML and other information (including cookies and headers) back to the client:
Provides server functionality for use in ASP pages, including creating objects and encoding strings:
Server Object Example
<%
' Create component instance
Set objEmail = Server.CreateObject("CDO.Message")
' Get server path
Dim filePath
filePath = Server.MapPath("data/users.txt")
' HTML encode output
Response.Write Server.HTMLEncode(userInput)
%>
ObjectContext Object
Lets you commit or abort transactions managed by Microsoft Transaction Server (MTS):
ObjectContext Example
<%@ Transaction=Required %>
<%
' Perform database operations
If successfulOperation Then
ObjectContext.SetComplete ' Commit transaction
Else
ObjectContext.SetAbort ' Rollback transaction
End If
%>
Scripting Language Scope
You can set the scripting language at three different levels:
Web site level: Changes the default scripting language for all pages in a specific web site
File level: Defines the scripting language for a single page using the @Language directive
Function level: Sets the scripting language only for a specific function within a page
Setting Script Language
<%@ Language="VBScript" %>
<%
' VBScript code here
Function GetGreeting()
GetGreeting = "Hello, World!"
End Function
%>
<SCRIPT LANGUAGE="JavaScript" RUNAT="Server">
// JavaScript code here
function getTimestamp() {
return new Date().toISOString();
}
</SCRIPT>
Key Takeaways
ASP's architecture provides a robust framework for server-side web development. By processing scripts on the server and providing built-in objects for common tasks, ASP lets you build dynamic web applications without worrying about browser compatibility or exposing your source code. While modern alternatives exist, understanding Classic ASP architecture gives you insight into the foundations of server-side web development.
Quick FAQ
What makes ASP language-agnostic?
ASP isn't limited to Microsoft-provided scripting languages like VBScript. It can be extended with any scripting language that supports the ActiveX scripting model, allowing you to choose the language that best fits your needs. This flexibility was a significant advantage when ASP was introduced, as it let developers leverage existing scripting knowledge.
How does ASP protect intellectual property?
All ASP code executes on the server, so your source code never reaches the client's browser. Only the generated HTML output is sent to users, protecting your intellectual property and eliminating browser compatibility concerns. This server-side execution model also means users can't view or modify your business logic.
What's the role of ASP built-in objects?
ASP provides six built-in objects (Application, Session, Request, Response, Server, and ObjectContext) that let you interact with the web server, manage user sessions, process form data, send output to browsers, and handle transactions without needing external libraries. These objects are immediately available in all your ASP pages with no setup required.