WebAppDebugger

   

Before we start with C++Builder 6 Enterprise features contained in WebSnap, we want to show you the new general enhancements that have been made in C++Builder 6 Web server application support (in other words, available in C++Builder 6 Professional, too).

In order to start a new Web server application, just click File, New “ ”Other and select the Web Server Application icon on the first tab from the Object Repository. This will show the new New Web Server Application Wizard, which now contains five possible Web server project targets instead of three (in contrast, Kylix only supports standard CGI and Apache DSO dynamic-shared objects on Linux).

The new options include support for Apache-shared modules (DLLs) on Windows as well as a special Web App Debugger executable. When you select the latter, you must also specify the CoClass Name of your Web server debug application. In the screenshot, as shown in Figure 22.1, we've specified DrBob42 as CoClass name:

Figure 22.1. New Web Server application types.

graphics/22fig01.gif

If you selected a Web App Debugger executable target and clicked OK, you not only get a new project with a Web module, but with a normal form as well. In fact, the form is the first unit of your project, so I've saved my project files in WADMainForm.cpp (for my Web App Debugger main form), WebMod.cpp (for my Web module), and DebugWebApp.bpr (for my main project file).

Default Web Action Item

Of course, before we can debug or even run a Web server application, we should first add at least one Web action item. Right-click the Web module, and start the Action Editor. Press Insert to create a new WebActionItem , set the Default property to true to make it the default (just in case), and let it return some dynamic HTML:

 void __fastcall TWebModule2::WebModule2WebActionItem1Action(        TObject *Sender, TWebRequest *Request, TWebResponse *Response,        bool &Handled)  {    Response->Content = "Hello, C++Builder 6 World!";  } 

Now, we'll show you how to debug this very simple Web server application using the C++Builder 6 Web Application Debugger (and without the need for an actual Web server on your machine).

Debugging

If you hit F9, you just run the application with the empty form. Just let it run there because to debug the Web server application, you need to start the Web Application Debugger from the Tools menu or from the CBuilder6\bin directory as webappdbg.exe . Starting the Web Application Debugger will give you the dialog box as shown in Figure 22.2.

Figure 22.2. The C++Builder 6 Web Application Debugger.

graphics/22fig02.gif

We must first click the Start button, which turns the Default URL label into a real "url" that we can click to activate the Internet Explorer browser that we can use to view the Web server application. As soon as we click the Default URL of the Web Application Debugger, we get a list of registered servers, which includes the ServerInfo.ServerInfo as well as DebugWebApp.DrBob42 (and perhaps other Web server debug applications that have already been registered on your machine), as can be seen in Figure 22.3.

Figure 22.3. Registered Servers.

graphics/22fig03.jpg

You can select a specific Web server application from the list and click GO to execute its default action. However, you can also first click the View Details link to see some more details of each Web server application. The details include the location of the Web server application as well as the ability to "Clean" the registry (that is, remove all information about this particular Web server application from the registry). This is very helpful because we still have numerous old MIDAS 3 (and new DataSnap) application servers that we forgot to unregister before we removed them. At least with the Web Application Debugger you can remove registry information from Web server applications even long after the actual applications have been removed. There's just one warning: Do not remove the registry information for the serverinfo.ServerInfo application because that's the one that actually provides the Web Application Debugger with the list of registered Web server applications. Without the registry information for serverinfo.ServerInfo , the Web Application Debugger won't be able to get that list again. That is, until we re-run serverinfo.exe from the CBuilder6\bin to register it again.

Debug Web Server Application

As you can see in the details listing, each Web server application has a number of ways by which it can be identified. We have the CISID (or the GUID), the ProgID (like the serverinfo.ServerInfo and DebugWebApp.DrBob42 ). The third way specifies the full path to the registered application. Finally, the File Status reflects whether the Web server application was actually found at the specified location. Sometimes, you get Not Found Here, which might indicate that you've cleaned up your project, but forgot to clean the registry (this has happened to me a few times more than I care to admit).

Either of the three underlined links can be used to actually trigger the default action of the Web server application, in our case resulting in a simple "Hello, world!" Alternately, you could go back to the View List option, and just select the Web server application you want to debug and press on the GO button. In both cases, the Web Application Debugger will make a request to your (running) Web server application. And, because the latter was running from within the C++Builder IDE, any breakpoint that was set will be triggered after you reach it (a really cool way to enable debugging of Web server applications without the need for a real Web server). When you're done debugging, you can always move the Web module to a "normal" Web server application (the old trick to use multiple projects, each with a different target, all sharing the same Web module).

After you're done debugging, you should first close the Web server application, and then the browser window. That leaves the Web Application Debugger window, where you can now click the Stop button again. The Web Application Debugger dialog will show some statistics, and even more interesting information on the Log tab, including the event, time, elapsed time, path, content length, and content type.

Let's now start with the main course: WebSnap, the new Web server application framework available in the Enterprise edition of C++Builder 6.


   
Top


C++ Builder Developers Guide
C++Builder 5 Developers Guide
ISBN: 0672319721
EAN: 2147483647
Year: 2002
Pages: 253

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net