ASP Basic Syntax Rules
In our ASP tutorial, each example provides 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 include server scripts, which are enclosed by delimiters <% and %>.
Server scripts execute on the server and can include valid expressions, statements, procedures, or operators of the scripting language of your choice.
The response.write Command
The response.write command is used to write output to the browser. The following example sends the text "Hello World" to the browser:
Example `<%
response.write("Hello World!") %>`
There is also a shorthand method for the response.write command. The following example also sends the text "Hello World" to the browser:
Example `<%
="Hello World!" %>`
Using VBScript in ASP
You can use several scripting languages in ASP. However, the default scripting language is VBScript:
The above example writes the text "Hello World!" into the body of the document.
Using JavaScript in ASP
If you need to set JavaScript as the default scripting language for a specific page, you must insert a language directive at the top of the page:
Note: Unlike VBScript, JavaScript is case-sensitive! You must write your ASP code using the appropriate case 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 use other languages to write scripts, such as PERL, REXX, or Python, you must install the corresponding script engine.