Table of Contents Previous Section

Request and Response Handling Methods

WebObjects defines four request and response handling methods that are invoked at particular points in the request-response loop if you implement them:

As with awake methods, the request and response handling methods can be implemented for an application and its components. Both versions of a request-handling method work identically, and can be used for identical purposes. You choose to implement a method for the application or for a component based on which is more appropriate for the behavior you need to provide. Generally, you implement request and response handling methods in the application when the request handling behavior should be invoked for every request. You implement request and response handling methods in a component when the request handling behavior should be invoked only for a particular page.

The WOWebScriptApplication class defines each of the request and response handling methods. Its implementations invoke the corresponding method defined in the corresponding Application.wos if one exists. For example, WOWebScriptApplication's willPrepareForRequest:inContext: invokes the willPrepareForRequest:inContext: method in the corresponding Application.wos if it exists. You can subclass WOWebScriptApplication and override the request and response handling methods, but it is more common to implement them in an application script.

WOComponentController defines each of the request and response handling methods as well, but WOComponentController's implementations do nothing. You can subclass WOComponentController and provide your own implementations, but it is equally common to implement a component's request and response handling methods in a component script. The WOComponentController subclass WOWebScriptComponentController overrides the request and response handling methods to invoke them in the corresponding component script if they exist.

The remainder of this section discusses some of the common uses of the request and response handling methods.

Table of Contents Next Section