ModjyEntireUriSpace » History » Revision 1
Serving an entire uri space with modjy¶
There are two main ways that you can configure a modjy web application to respond to the entire URI space of a virtual host.
Rename the web application.¶
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.
If you follow this strategy, then you don't need to read any further on this page.
By configuring your container.¶
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.
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.
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
<servlet> <servlet-name>modjy</servlet-name> <servlet-class>com.xhaus.modjy.ModjyJServlet</servlet-class> <!-- Parameters omitted --> <load-on-startup>1</load-on-startup> </servlet>
Creating a mapping for the entire uri space¶
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.
<servlet-mapping> <servlet-name>modjy</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
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 6 classloader hierarchy, the level that is appropriate for container-wide servlets is $tomcat_home/lib.
So hopefully now you've got modjy/WSGI taking care of your entire URI space, i.e. SCRIPT_NAME="". Cool!