This document describes how to set up a working JSP system that connects to Apache on Windows (I'm working on 2K). This
system lets you process JSP files that are in the ordinary Web server
folders as well as use specific Web applications.
The system created is a simple one that handles only a single host,
not virtual hosts (although if you know about virtual hosts maybe you
can extend it). We are using Apache 2.0.48, JK 2.0.43, and Tomcat
4.1.29 (the current versions at time of first writing).
Important: all other documents describing this process
are wrong. They miss out vital configuration steps. You're going
to spend all day tearing your hair out if you believe them, so don't do
that, that's what I just did.
Also, don't bother looking at Apache's docs on this subject - unless
they rewrote them since, they're utterly worthless.
Also important: I make no
guarantees about security
implications (or whether this actually works for that matter; hey, most
likely this document is wrong too).
And this document doesn't cover other versions of the software, like
Apache 1 for example.
Really really important: Under no circumstances contact me
asking for help configuring your software. Don't email me about that. I
don't know shit about server configuration. If it doesn't work, ask
somebody who does, not me. (On the other hand, if you are somebody who knows about server
configuration and you notice anything hideously wrong in here, let me
know, maybe I'll fix it, thanks.)
Thanks to Eric Barr for pointing out an omission in the previous
version of this text.
Remember the directories you used to install Apache and Tomcat in. I'm going to call those <APACHE> and <TOMCAT>.
mod_jk2-2.0.43.dll) in it. Copy this DLL into
<APACHE>/modules. (The other files in there are all called .so and yours is a DLL - don't sweat it, this is right.)
Begin by editing the file
You might want to make a backup first.
First thing is to make sure Tomcat is looking in the same place as
Apache for your JSP files. Otherwise it ain't gonna find them, even if
Apache does pass on the request. (If you only want to use Tomcat web
applications and don't need JSP files processed inside your Apache
folders, then you can skip this step.)
<Context path="" docBase="<APACHE>/htdocs"
debug="0" reloadable="true" crossContext="true"/>
(Obviously, if you changed your Apache document root from the default, use that instead.)
<Context path="/examples">; be careful, you need to get the whole thing all the way down to the
</Context>and there are nested comments. Of course, if you actually want the examples, don't do this.
You're probably thinking, huh? my Apache doesn't have one of those
files. Well, it doesn't yet, but you're going to make one.
# Doesn't work without this (I don't know why)
# Example socket channel, override port and host.
# define the worker
Finally, a file you've actually heard of! Add this to
(e.g. at the end):
LoadModule jk2_module modules/mod_jk2-2.0.43.dll
JkUriSet worker ajp13:localhost:8009
JkUriSet worker ajp13:localhost:8009
You can probably see that this causes all files ending
and anything beginning with
/tomcat-docs (you can get rid
of that one if you like, it's just an example), to be processed by
Tomcat instead of Apache.
Any webapps (like
tomcat-docs) will come from within
the Tomcat webapps folder, but all your JSP files can be placed inside
the normal Apache root.
If you want to make other URIs be processed by Tomcat, you can just
add them in the same way. Hopefully it's obvious how - and because this
httpd.conf you don't have to remember some other
bizarre configuration file when you're making changes.
You'll need to use the Services control panel.
Rumours suggest you should wait a few seconds between these, but I
don't think it matters any more (maybe it once did).
Make sure Tomcat webapps still work by accessing
- you should find that this works, even though you accessed it via
Apache (port 80) and the files are within Tomcat's webapps folder.
That's because it's configured to pass on the request in
Within your Apache documents tree, create a file test.jsp:
<%= new java.util.Date() %>
http://localhost/test.jsp and you should see
(after a pause, first time round) the current date. Woo! Again, that's
*.jsp is configured to pass on the request, in
That's all for now folks!