Creating Web server applications with Web Snap

If you look at the source code for WebSnap, you will discover that WebSnap comprises hundreds of objects. In fact, WebSnap is so rich in objects and features that you could spend a long time studying its architecture in detail before understanding it completely. Fortunately, you really don't need to understand the whole WebSnap system before you start developing your server application.

Here you will learn more about how WebSnap works by creating a new Web server application.

To create a new Web server application using the WebSnap architecture:

1 Choose File I New I Other.

2 In the New Items dialog box, select the WebSnap tab and choose WebSnap Application.

A dialog box appears (as shown in Figure 35.1).

3 Specify the correct server type.

4 Use the components button to specify application module components.

5 Use the Page Options button to select application module options.

6 Check the Cross Platform box if you intend to build and deploy your application on both Windows and Linux servers.

Figure 35.1 New WebSnap application dialog box

Figure 35.1 New WebSnap application dialog box

Selecting a server type

Select one of the following types of Web server application, depending on your application's type of Web server.

Table 35.2 Web server application types

Server type

ISAPI and NSAPI

Apache

CGI stand-alone

Web App Debugger executable

Description

Sets up your project as a DLL with the exported methods expected by the Web server.

Sets up your project as a DLL with the exported methods expected by the appropriate Apache Web server. Both Apache 1 and 2 are supported.

Sets up your project as a console application which conforms to the Common Gateway Interface (CGI) standard.

Creates an environment for developing and testing Web server applications. This type of application is not intended for deployment.

Specifying application module components

Application components provide the Web application's functionality. For example, including an adapter dispatcher component automatically handles HTML form submissions and the return of dynamically generated images. Including a page dispatcher automatically displays the content of a page when the HTTP request pathinfo contains the name of the page.

Selecting the Components button on the new WebSnap application dialog (see Figure 35.1) displays another dialog that allows you to select one or more of the Web application module components. The dialog, which is called the Web App Components dialog, is shown in Figure 35.2.

Figure 35.2 Web App Components dialog

Web App Components

Web App Components

Application Adapter

HlTApplicatiorAdapter

J

End User Adapter

1T E ndU serAdapter

J

Page Dispatcher

1T PageD ispatcher

J

Adapter Dispatcher

1T Adapt er D ispatcher

J

Dispatch Actions

iTWebD ispatcher

J

Locate File Service

1T LocateFileS ervice

J

Sessions Service

1T S essionsS ervice

J

User List Service

|TWebUserList

Help

The following table contains a brief explanation of the available components:

Table 35.3 Web application components Component type Description

Application Adapter Contains information about the application, such as the title. The default type is TApplicationAdapter.

Contains information about the user, such as their name, access rights, and whether they are logged in. The default type is TEndUserAdapter. TEndUserSessionAdapter may also be selected.

Examines the HTTP request's pathinfo and calls the appropriate page module to return the content of a page. The default type is TPageDispatcher.

Automatically handles HTML form submissions and requests for dynamic images by calling adapter action and field components. The default type is TAdapterDispatcher.

End User Adapter Page Dispatcher Adapter Dispatcher

Table 35.3 Web application components (continued)

Component type Description

Dispatch Actions

Locate File Service

Sessions Service

User List Service

Allows you to define a collection of action items to handle requests based on pathinfo and method type. Action items call user-defined events or request the content of page-producer components. The default type is TWebDispatcher.

Provides control over the loading of template files, and script include files, when the Web application is running. The default type is TLocateFileService.

Stores information about end users that is needed for a short period of time. For example, you can use sessions to keep track of logged-in users and to automatically log a user out after a period of inactivity. The default type is TSessionsService.

Keeps track of authorized users, their passwords, and their access rights. The default type is TWebUserList.

For each of the above components, the component types listed are the default types shipped with the IDE. Users can create their own component types or use third-party component types.

Selecting Web application module options

If the selected application module type is a page module, you can associate a name with the page by entering a name in the Page Name field in the New WebSnap Application dialog box. At runtime, the instance of this module can be either kept in cache or removed from memory when the request has been serviced. Select either of the options from the Caching field. You can select more page module options by choosing the Page Options button. The Application Module Page Options dialog is displayed and provides the following categories:

• Producer: The producer type for the page can be set to one of AdapterPageProducer, DataSetPageProducer, InetXPageProducer, PageProducer, or XSLPageProducer. If the selected page producer supports scripting, then use the Script Engine drop-down list to select the language used to script the page.

Note The AdapterPageProducer supports only JScript.

  • HTML: When the selected producer uses an HTML template this group will be visible.
  • XSL: When the selected producer uses an XSL template, such as TXSLPageProducer, this group will be visible.
  • New File: Check New File if you want a template file to be created and managed as part of the unit. A managed template file appears in the Project Manager and has the same file name and location as the unit source file. Uncheck New File if you want to use the properties of the producer component (typically the HTMLDoc or HTMLFile property).
  • Template: When New File is checked, choose the default content for the template file from the Template drop-down. The standard template displays the title of the application, the title of the page, and hyperlinks to published pages. The blank template creates a blank page.
  • Page: Enter a page name and title for the page module. The page name is used to reference the page in an HTTP request or within the application's logic, whereas the title is the name that the end user will see when the page is displayed in a browser.
  • Published: Check Published to allow the page to automatically respond to HTTP requests where the page name matches the pathinfo in the request message.
  • Login Required: Check Login Required to require the user to log on before the page can be accessed.

You have now learned how to begin creating a WebSnap server application. The

WebSnap tutorial describes how to develop a more complete application.

+2 -1

Post a comment