tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <>
Subject Re: Why doesn't my context work?
Date Sat, 17 Sep 2005 02:31:59 GMT

--- Michael Sullivan <> wrote:

> OK.  For clarification I am running
> tomcat-5.0.27-r6.  I want user's
> tomcat files to be read from
> /home/*/webspace/webapps.  My personal
> account is michael so my personal tomcat directory 
> would
> be /home/michael/webspace/webapps .  Just for the
> sake of arguments I
> created a directory called user under
> /home/michael/webspace/webapps and
> moved my jsp files into it.
> My /opt/tomcat5/conf/Catalina/localhost/user.xml
> file looks like this
> now:
> <Context
> docBase="/home/michael/webspace/webapps/user"
>         debug="0" privileged="true">
> </Context>

You don't need privledged="true", so let's remove

> I restarted Tomcat.  I am using mod_jk and when I go
> to
> I see the Tomcat
> start page.  However,

Good, you're using mod_jk.  You will need to do some
Apache configuration in order for this to work.

I am going to assume that /home/* lies outside of the
DocumentRoot directory tree.

1. Get Apache to recognize web directories outside of
the DocumentRoot tree.  There are several ways of
doing this.  One such way is given in the actuall
httpd.conf file that comes with the stock Apache.

Basically you need to give a set of Directory
directives that give Apache access to the material in
the home directories.

If you use the userdir_module in Apache, then
~username/<directory> will become a part of the web
space (if you take the comments out).

If you do this by hand, you'll need to give both
Directory directives and an Alias directive to move it
into the web space that Apache serves.

2. Once you do that, you'll need to add JkMount
statements as well.  I suspect that JkMount statements
will respond to Alias directives since JkMount deals
with web space and not directories.

I don't know if JkMount interacts with the
userdir_module.  In other words, I don't know what
will happen if you put in a JkMount statment that

JkMount /~*/*.jsp tomcat

It would be interesting to find out if that would end
up mapping to /~<username>/<directory>/*.jsp where
<username> is the user name and <directory> is the
value of UserDir.

3. Once you do that, it's always nice to make a small
WEB-INF/web.xml, even for plain jsp pages.  Something
like the following should work:

<?xml version="1.0" encoding="UTF-8"?>
"-//Sun Microsystems, Inc.//DTD Web Application
<display-name>Beginning JSP</display-name>
<description>Container for quick

Sorry for the wrapping.

In short, you need to do the following three steps.

1. Make sure your Apache server knows about
directories outside of DocumentRoot.  Use Directory
and Alias directives or userdir_module.

2. Use JkMount to map the expected incoming URLs to
the Tomcat server.  Experiment to see if JkMount picks
up on the substitutions done by userdir_module.

3. Make a small WEB-INF/web.xml with the appropriate
structure.  Creating a proper web application is
useful, especially once you start adding servlets to
the mix.


> when I go to I
> get Tomcat 404
> Resource Not Available for /user/index.jsp .  You
> reprinted the
> paragraph from the Tomcat documentation and it made
> the same amount of
> sense to me as it did when I read it in the Tomcat
> docs:  Basically
> none.

Hmm, let me see if I can give my explanation.

If you do not have a leading / in your appBase value,
then the containing <Host>'s docBase value gets stuck
on in front.  In other words:


>From the <Host> container documentation, if the
appBase value does not have a leading /, then it is
taken relative to $CATALINA_BASE.  The resulting path
to the application looks like:


If you haven't defined $CATALINA_BASE, it defaults to
the same value as $CATALINA_HOME.  The resulting path
to the application the looks like:



In combination with the userdir_module from Apache to
get the directories into Apache's web space, you might
also want to take a look at user web applications
section of the <Host> container document.  The section
is toward the end of:


It looks like you could use the userdir_module,
appropriate JkMount directives, and the howto in the
<Host> container document to construct a pretty
flexible environment where every user could have a web
applications directory.


Yahoo! Mail - PC Magazine Editors' Choice 2005

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message