ASP basic syntax rules
In our ASP tutorial, every example provides the hidden ASP source code. This makes it easier for you to understand how they work.
Writing output to the browser
ASP files usually contain HTML tags, just like HTML files. However, ASP files can also contain server scripts, which are enclosed by the delimiters <<% and %>.
Server scriptsexecuted on the server, and can contain valid expressions, statements, procedures, or operators of your chosen scripting language.
The response.write command
The response.write command is used to write output to the browser. The following example sends a piece of text to the browser: "Hello World":
Example
<%
response.write("Hello World!")
%>
Demo Example »
There is also a shorthand form of the response.write command. The following example also sends a piece of text to the browser: "Hello World":
Example
<%
="Hello World!"
%>
Demo Example »
Using VBScript in ASP
You can use several scripting languages in ASP. However, the default scripting language is VBScript:
<%
response.write("Hello World!")
%>
The example above writes the text "Hello World!" to the body section of the document.
Using JavaScript in ASP
If you need to set JavaScript as the default scripting language for a particular page, you must insert a language declaration line at the top of the page:
<%@ language="javascript"%>
<%
Response.Write("Hello World!")
%>
**Note:** Unlike VBScript, JavaScript is case sensitive! You must write your ASP code with different letter cases as required by JavaScript.
Other scripting languages
ASP works natively with VBScript and JScript (JScript is Microsoft's implementation of JavaScript). If you want to write scripts in other languages, such as PERL, REXX, or Python, you must install the appropriate scripting engine.