1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

RTL reference|Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To
ISAPI tutorial for Delphi developers
Page 4: Web Actions
 More of this Feature
• Pg 1: Intro to web-broker
• Pg 2: Using this tutorial
• Pg 3: Getting started
• Pg 5: The first ISAPI app
• Pg 6: TWebRequestObject
• Pg 7: Request-responding
• Pg 8: TPageProducers
• Pg 9: Cookies made easy
• Pg 10: Stateless HTTP
• Pg 11: DB enabled apps
• Pg 12: FAQ
• Pg 13: DB apps - Part 1
• Pg 14: DB apps - Part 2
• Pg 15: DB apps - Part 3
 Join the Discussion
"Post your questions, concerns, views and comments to this article..."
 Related Resources
• Internet programming
• CGI and ISAPI with Delphi

Before we start our first application (be patient, it will be the next chapter), I want to take a quick look at the heart of all web server extensions: The WebActions.

Let's take a look at what a request to our application might look like:


As you can see, each call to the application is composed of:

1. The domain name

2. The virtual directory where the application is located

3. The name of the application (including it's extension)

4. And last but not least, the action.

In this case, our action is called "theaction". This last parameter (action) can be obtained in our application with the PathInfo property of the TWebRequest object (we will look into this in more depth later).

Once the request is made, the Dispatcher tries to match the PathInfo with an action. Once it finds one it then let's the action take care of the request. We will see later that you can actually make an action reply to a request but not "handle" it. That is, it sort of does some of the work and then passes it on to someone else (another action).

If an action is not found that matches the PathInfo, then the Dispatcher looks for the default action. You can set an action to be default by just assigning the Default property to True. Note that you can only have on default action per application. It doesn't matter what MethodType the default action is or whether it's enabled or not.

   Method Types
Each action can have a different method type. These are: mtGet, mtPut, mtHead, mtPost and mtAny. I won't go into details about each one (I assume that you know a bit about the HTTP protocol). I normally leave this set at mtAny.

   Before/After Dispatch
The TWebModule has four events. As with any other form it has the OnCreate and OnDestroy. Remember, as mentioned previously, if you have CacheConnections set to True (default), these events will only be fired once.

There are another two interesting and useful events called BeforeDispatch and AfterDispatch. The BeforeDispatch event gets called whenever an action is called in the application and it's fired before the actual action. AfterDispatch is called after an action has been fired. Later, when we look at more advanced topics such as cookies and security, you will see that these events (specially the first one) come in very handy.

   Handled Parameter
Both the Before/After Dispatch events an every web action has a paramerter passed by reference called Handled. By default the value is True. Setting it to false indicates that the request has not been fully handled and that some other request will be called.

Ok, that's enought theory. Let's go to the next topic and let's get down to some coding.

Next page > The first ISAPI application > Page 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15

All graphics (if any) in this feature created by Zarko Gajic.

 More Delphi
· Learn another routine every day - RTL Quick Reference.
· Download free source code applications and components.
· Talk about Delphi Programming, real time.
· Link to the Delphi Programming site from your Web pages.
· Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC.
· NEXT ARTICLE: ADO Cursors - DB/10.
Chapter ten of the free Delphi Database Course for beginners. How ADO uses cursors as a storage and access mechanism, and what you should do to choose the best cursor for your Delphi ADO application.
 Stay informed with all new and interesting things about Delphi (for free).
Subscribe to the Newsletter

 Got some code to share? Got a question? Need some help?

©2017 About.com. All rights reserved.