What is ASP? Which is ASP basic syntax? Objects, methods, properties, events and collections?
AH! Do we really know what we are talking about?
The following post is just a quick reference guide for all those things. It is meant for beginners, but I believe that even experienced programmers might find it useful... just to check if everything we know is correct.
What is ASP?
ASP stands for Active Server Page. In a previous post I've already defined it as a scripting engine. That is because we usually and wrongfully consider ASP as a programming language.We can use different programming languages in ASP pages, such as VBScript or JScript. Usually, web developers use VBScript, which is ASP default language.
The ASP engine is managed by IIS (Internet Information Services), working in a MS Windows environment. I know that it is possible to use ASP with other web server applications such as Apache.
It is worth mentioning that ASP is working with PWS as well. PWS (Personal Web Server) is a small but fully functional version of IIS and it was available on older operating systems like WIN 95 and 98 (oh what a leap in the past!).
Basic syntax
The basic syntax of ASP commands is:
<%
...asp commands...
%>
Inside the <% and %> we insert server scripts which are run on the server side. That is a great plus, because it is the server that is doing all the dirty jobs. If we try to see an ASP page code, all we will see is the HTML: the scripts will not be visible.
Objects, methods, properties, events, collections
ASP commands use objects. Objects may have methods, properties, events and collections. Now this is getting complicated, isn't it? Let's try to understand it all.ASP objects are:
- Application;
- Response;
- ObjectContext;
- Session;
- ASPError;
- Request;
- Server.
I tried to summarise all the relation between objects and methods, properties, events or collections in the following table:
Object
|
Method
|
Property
|
Event
|
Collection
|
Application | Contents.Remove Contents.removeAll Lock Unlock |
OnEnd OnStart |
Contents StaticObjects |
|
Response | AddHeader AppendToLog BinaryWrite Clear End Flush Redirect Write |
Buffer CacheControl CharSet ContentType Expires ExpiresAbsolute IsClientConnected Status |
CodePage Cookies LCID |
|
ObjectContext | SetAbort SetComplete |
OnTransactionAbort OnTransactionCommit |
||
Session | Abandon Contents.Remove Contents.removeAll |
CodePage LCID SessionID Timeout |
OnEnd OnStart |
Contents StaticObjects |
ASPError | ASPCode ASPDescription Category Column Description File Line Number Source |
|||
Request | BinaryRead | TotalBytes | ClientCertificate Cookies Form QueryString ServerVariables |
|
Server | CreateObject Execute GetLastError HTMLEncode MapPath Transefer URLEncode |
ScriptTimeout |
The above is just a part of the possible ASP commands. The Server.CreateObject command is a good example, because using it we can create other objects like the FileSystemObject which has properties and methods:
Object
|
Method
|
Property
|
FileSystemObject | BuildPath CopyFile CopyFolder CreateFolder CreateTextFile DeleteFile DeleteFolder DriveExists FileExists FolderExists GetAbsolutePathName GetBaseName GetDrive GetDriveName GetExtensionName GetFile GetFileName GetFolder GetParentFolderName GetSpecialFolder GetTempName MoveFile MoveFolder OpenTextFile |
Drives |
The FileSystemObject has, for example a method called CreateTextFile which has properties and methods. The same for the GetDrive, or the GetFile methods.
The Server.CreateObject can create ADO objects (with their properties, methods and collections) which we use to query databases. We use for example the ADODB.Command in order to execute query against a database.
Simplify, please...
Yes, I know. It seems there's no logic in it, but, believe me, there is. What we basically need to understand is that it is all related to objects which have properties, methods and collections. To simplify it a bit, we have ready-made objects, or we can "create" other objects. Ok, I already hear screams from experienced programmers. I know I'm trying to simplify the whole thing a little too much...
Conclusions
In order to understand ASP we can use different approaches. I believe that trying to squeeze all ASP concepts in a single post is almost impossibile. There are many books available that will guide a beginner step by step and that will explain everything about ASP. At the same time, we can browse many web sites that try to cover all the ASP related topics.So, the first possible approach is to look into those books or web sites.
Another approach is to look for solutions when an issue arises. The usual path is something like: issue -> search solution -> find object, methods etc that will provide a solution -> understand in depth the specific solution (object, method etc) -> apply the solution.
The second approach is the one that I've followed in the past. When we will get enough experience, we can try to organise mentally all the acquired knowledge. That's what I suggest.
I hope that the above post will help you in starting to use ASP or in re-organising your thoughts about it. I would like you to share your ideas on the topic, so please use the comments section below.
In the mean time, have a nice day and keep on reading.
0 thoughts:
Post a Comment
Comments are moderated. I apologize if I don't publish comments immediately.
However, I do answer to all the comments.