Please browse the categories below to previous answers to questions like yours. If you do not find the answer for your particular situation, ask for help on the appropriate mailing list.
(Answer) (Category) Java Apache Project : (Category) Apache JServ 1.0 : (Category) Configuration :
Using mod_rewrite to map arbitrary URLs to servlets


----------
From: Steve Snodgrass ssnodgra@fore.com
To: Java Apache Users java-apache-users@list.working-dogs.com
Subject: Using mod_rewrite to map arbitrary URLs to servlets
Date: Thu, Apr 29, 1999, 1:58 PM


On Wed, Apr 28, 1999 at 11:44:33PM +0200, Jean-Luc Rochat wrote:
> use mod_rewrite for this one.

Thanks very much, mod_rewrite turned out to be the ticket for this problem.

I thought I'd summarize the solution to my problem to the list since someone
else may run into this.  Basically, this is a general way to map *any* URL to
a java servlet, including URLs in directories that you are already serving
HTML files out of.  This assumes that you have a zone set up to run servlets
under the /servlets URL.

First, you must have the mod_rewrite module, and the JServ module must come
*before* mod_rewrite in the AddModule list.  In other words:

AddModule mod_jserv.c
AddModule mod_rewrite.c

Then, you set up rewrite rules like this:

RewriteEngine on
RewriteRule ^/mantix/mxbooker$ /servlets/com.mx.webtime.servlets.MxBooker [PT]
RewriteRule ^/mantix/mxclerk$ /servlets/com.mx.webtime.servlets.MxClerk [PT]

Result:

URL /mantix/mxbooker runs servlet com.mx.webtime.servlets.MxBooker
URL /mantix/mxclerk  runs servlet com.mx.webtime.servlets.MxClerk

The key is using the [PT] flag (passthrough) with mod_rewrite, or else the
URLs will try to refer to files, which of course don't exist.
[Append to This Answer]
Previous: (Answer) (INFO) wrapper: VM died too many times w/in 5 second intervals (6); no more tries
Next: (Answer) How to get SunJSP 1.0 Ref imp to work in Apache JServ???
This document is: http://java.apache.org/faq/?file=131
[Search] [Appearance] [Show Expert Edit Commands]
This is a Faq-O-Matic 2.709.
Please browse the categories below to previous answers to questions like yours. If you do not find the answer for your particular situation, ask for help on the appropriate mailing list.