Apache


URL-Dispatching

Before we discuss using another application as a front end to Resin, let's see how a request gets from the client browser through the front-end Web server to the Resin servlet engine. The mechanism that allows an HTTP request to navigate through the applications is called URL-Dispatching.

The three Web servers we discuss in this chapter are Apache, IIS, and Netscape's iPlanet. For each of the servers, a plug-in to the server application is available that handles dispatching of URLs:

  • mod_caucho for Apache

  • isapi_srun for IIS

  • nsapi for Netscape

These plug-ins handle the dispatching of a URL to the Resin engine as well as the transfer of the Request and Response objects. For each of these modules, information is gathered about the current environment from the Resin configuration file. The modules read information from the <host>, <web-app>, and <servlet-mapping> elements.

From <host>, the modules gain information about the current virtual hosts. From <web-app>, the modules learn about the various applications configured on the machine, and they read <servlet-mapping> to learn the selected URLs. The most important tag to the plug-in is <servlet-mapping> because it is able to determine which URLs need to be passed to the Resin servlet engine.

The plug-in finds the <url-pattern> element within <servlet-mapping>. As you've seen, <url-pattern> has the job of matching the URL being requested. A <reg-exp> element is also available, but the Resin plug-ins don't recognize it. Within <servlet-mapping> are two special names that can be used in the servlet-name attribute: plugin-match and plugin-ignore.

Consider the following configuration example:

 <servlet-mapping url-pattern='/forresin/*'                  servlet-name='plugin_match'/> <servlet-mapping url-pattern='/otherpages/*'                  servlet-name='plugin_ignore'/> 

These <servlet-mapping> elements tell the Resin plug-in how to handle pages it might be given by a client Web browser. In the first example, the element checks all incoming URLs with the pattern /forresin/*. If it finds this pattern, the plug-in automatically sends the URL to the Resin servlet engine. In the second example, the element checks all incoming URLs with the pattern /otherpages/*. All of these pages are kept with the external server. These directives are useful for directing an entire directory of pages to Resin.

As you'll see shortly, it's also possible to allow Apache's httpd.conf configuration file to handle dispatching duties as well. You accomplish this using the <Location> and SetHandler directives. For example:

 <Location /forresin/*>   SetHandler caucho-request </Location> 

These directives match all /forresin/* URLs and signal that Resin should handle them.




Mastering Resin
Mastering Resin
ISBN: 0471431036
EAN: 2147483647
Year: 2002
Pages: 180

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