Scenario and Overview

Unaltered Turbine URLs look like this: http://www.foo.com:8080/CONTEXT/servlet/MAPPING/template/Foo.vm.
But you want shorter URLs, or you don't like exposing the use of servlets in the URL. Maybe this url would suit you better: http://www.foo.com:8080/po/s/la/template/Foo.vm

The bulk of the url is defined by the servlet api and is outside of the control of Turbine:

http://www.foo.com/CONTEXT/servlet/MAPPING/template/Foo.vm
                   [ servlet api defined ][ turbine       ]
This HOWTO describes how you can control the servlet part of the url in Tomcat. For other servlet environments you'll have to consult their documentation.

Three parts of the url will be addresed:

  1. the web application context (CONTEXT in the example above),
  2. the servlet prefix (servlet),
  3. and the servlet mapping (MAPPING).

The Context

You need to register the context with Tomcat. If you have given your application a short name like 'po' and placed it correctly in the webapps directory, then you won't need to do anything special. Tomcat will find the directory, and add a context. If you have a long application name like 'mywonderfulapp', add the following lines to Tomcat's server.xml file:

<Context
    path="/po"
    docBase="webapps/mywonderfulapp"
    reloadable="true"
    debug="0"
    trusted="false" >
</Context>

Everthing after the docBase= line is obviously up to you. This tells Tomcat to add a context named 'po' with the docbase of your application.

The Servlet Prefix

Modifying the servlet prefix also requires editing Tomcat's server.xml file. Tomcat will use this prefix to determine if a given request is for a servlet. Edit the following lines:

<RequestInterceptor
    className="org.apache.tomcat.request.InvokerInterceptor"
    debug="0" prefix="/s/" />

With this modification, Tomcat recognize requests containing /s/ in the url as a servlet request and will look for the servlet in the web.xml descriptor.

The Servlet Name

This is defined in web.xml (which you will find here: webapps/WEB-INF/web.xml). This is automatically given the name of your application in Turbine. To change it, simply edit the web.xml file as follows:

<servlet-name>
    la
</servlet-name>

If you are using Tomcat standalone, then you are done and your url is now http://servername:port:/po/s/la

If you are running Apache and mod_jk

... you will need to change your mod_jk.conf file to include the following:

#########################################################
# Auto configuration for the /po context starts.
#########################################################

#
# Make Apache aware of the location of the context
#
Alias /po "serverroot/webapps/mywonderfulapp"
<Directory "serverroot/webapps/mywonderfulapp">
     Options Indexes FollowSymLinks
</Directory>

#
# Mount all JSP files and the /servlet/ uri to Tomcat
#
JkMount /po/s/* ajp12
JkMount /po/*.jsp ajp12

#
# Prohibit users from directly accessing WEB-INF
#
<Location "/mywonderfulapp/WEB-INF/">
     AllowOverride None
     deny from all
</Location>

#
# Prohibit users from directly accessing META-INF
#
<Location "/mywonderfulapp/META-INF/">
     AllowOverride None
     deny from all
</Location>

#######################################################
# Auto configuration for the /po context ends.
#######################################################

document created August 14, 2001