ModjyEntireUriSpace » History » Version 2

Alan Kennedy, 2015-07-04 05:32 PM
Updated tomcat links to Tomcat 8

1 1 Alan Kennedy
h1. Serving an entire uri space with modjy
2 1 Alan Kennedy
3 1 Alan Kennedy
There are two main ways that you can configure a modjy web application to respond to the entire URI space of a virtual host.
4 1 Alan Kennedy
5 1 Alan Kennedy
h2. Rename the web application.
6 1 Alan Kennedy
7 1 Alan Kennedy
Under Apache Tomcat, a web application that is called *ROOT* is treated specially, and is called to service all requests to the root of the URI space. So a simple way for modjy web applications to service an entire URL space under Apache Tomcat is rename the *modjy_webapp* directory to *ROOT*, and then copy that into the *webapps* subdirectory as before.
8 1 Alan Kennedy
9 1 Alan Kennedy
If you follow this strategy, then you don't need to read any further on this page.
10 1 Alan Kennedy
11 1 Alan Kennedy
h2. By configuring your container.
12 1 Alan Kennedy
13 1 Alan Kennedy
Alternatively, if you want to configure modjy to serve requests for all URIs, i.e. */** then you cannot do so in the modjy_servlet web.xml file. Instead you can move the servlet up the configuration hierarchy.
14 1 Alan Kennedy
15 1 Alan Kennedy
Every servlet container has a container-wide configuration file where container-wide servlets are configured. Some, such as Tomcat, split this function across multiple configuration files. Under Tomcat 6, this file is located at *$tomcat_home/conf/web.xml*. Other containers, e.g. "Caucho Resin":, permit this kind of configuration directly in the main server configuration file, i.e. *resin.conf*.
16 1 Alan Kennedy
17 1 Alan Kennedy
You will need to configure a declaration for the modjy servlet in this higher level configuration file. You can probably copy this definition directly from the web.xml file that comes with modjy. After that, you will need to make the container map all URIs to the modjy servlet. The servlet definition will look something like this
18 1 Alan Kennedy
19 1 Alan Kennedy
20 1 Alan Kennedy
21 1 Alan Kennedy
22 1 Alan Kennedy
23 1 Alan Kennedy
    <!-- Parameters omitted -->
24 1 Alan Kennedy
25 1 Alan Kennedy
26 1 Alan Kennedy
27 1 Alan Kennedy
28 1 Alan Kennedy
h3. Creating a mapping for the entire uri space
29 1 Alan Kennedy
30 1 Alan Kennedy
Possibly your container will have a default servlet to which requests are sent when they are not mapped to any other servlet. Under Tomcat, this is called the *default* servlet, and is implemented by the java class *org.apache.catalina.servlets.DefaultServlet*. The *servlet-mapping* for this servlet will contain a *<url-pattern>/</url-pattern>*. You could change this servlet-mapping to reference the modjy servlet definition you defined above, or create a new servlet mapping if one does not already exist. That mapping should look something like this.
31 1 Alan Kennedy
32 1 Alan Kennedy
33 1 Alan Kennedy
34 1 Alan Kennedy
35 1 Alan Kennedy
36 1 Alan Kennedy
37 1 Alan Kennedy
38 1 Alan Kennedy
39 1 Alan Kennedy
h3. Placing jython.jar
40 1 Alan Kennedy
41 2 Alan Kennedy
However, you're not finished yet! Because you've moved the modjy servlet up the container hierarchy, you must also move the jython.jar file up the classloader hierarchy. Such matters tend to be container specific, and so you may need to read on the classloader hierarchy of your container to know where to place the jython.jar file. Under the "Tomcat classloader hierarchy":, the level that is appropriate for container-wide servlets is *$tomcat_home/lib*.
42 1 Alan Kennedy
43 1 Alan Kennedy
So hopefully now you've got modjy/WSGI taking care of your entire URI space, i.e. *SCRIPT_NAME=""*. Cool!
Add picture from clipboard (Maximum size: 10 MB)