For an example of how Service directives work, consider what happens when the server receives a request for the URL D:/server_name/jos.html. In this case, all directives executed by the server are in the default object.
The following NameTrans directive translates the requested URL to D:/Sun/WebServer61/server1/docs/jos.html:
NameTrans fn="document-root" root="D:/Sun/WebServer61/server1/docs"
Assume that the PathCheck directives all succeed.
The following ObjectType directive tells the server to look up the resource’s MIME type in the MIME types table:
The server finds the following entry in the MIME types table, which sets the type attribute to text/html:
The server invokes the following Service directive. The value of the type parameter matches anything that does not begin with magnus-internal/. (For a list of all wildcard patterns, see Chapter 9, Using Wildcard Patterns client.)
Service method="(GET|HEAD|POST)" type="*~magnus-internal/*" fn="send-file""
Here is an example that involves using another object:
The following NameTrans directive assigns the name personnel to the request.
NameTrans fn=assign-name name=personnel from=/personnel
As a result of the name assignment, the server switches to processing the directives in the object named personnel. This object is defined as:
<Object name="personnel"> Service fn="index-simple" </Object>
The personnel object has no PathCheck or ObjectType directives, so the server processes the PathCheck and ObjectType directives in the default object. Let's assume that all PathCheck and ObjectType directives succeed.
When processing Service directives, the server starts by considering the Service directive in the personnel object, which is:
The server executes this Service directive, which calls the index-simple function.
Since a Service directive has now been executed, the server does not process any other Service directives. (However, if the matching object had not had a Service directive that was executed, the server would continue looking at Service directives in the default object.)