tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <>
Subject Re[2]: Tomcat redirect
Date Tue, 07 May 2002 16:01:02 GMT
Hello joshua,

Well, actually, all you've done here is specify a context called
"servlet" which has it's docbase sitting on the file system as
"/spike/servlet".  This would assume that you are on a Unix system and
you have a directory called "spike" off the root of your sytem with a
directory called "servlet" inside that.

In this case, the address to your webapp would be:

However, I would avoid calling your context "servlet" because I think
it will conflict with the default servlet mapping that Tomcat provides
for you.  In fact I think you are confusing the /servlet/* mapping that Tomcat provides
for all webapps via its default web.xml with setting up a context.

Let's assume that you place your new context in Tomcat's 'webapps"
directory and it is called "myservlets".  You can either not bother
explicitly stating the <Context> for this webapp in the Server.xml and
let Tomcat create a default one for it, or you can go ahead and
specify it like this:

<Context path="/myservlets" docBase="myservlets">

The path says that requests to refer to
a Tomcat-served Servlet context.

The docBase says where the context's directory exists on the file
system.  Here, we are saying that it exists in the current directory
(relative the webapps directory).  You could also put this elsewhere
on your file system, but you must then provide a path relative to
webapps directory by saying something like "../../../../myservlets"
which says "myservlets" is located 4 directories back from wherever
the "webapps" directory exists or you can specify a hardcoded path
like "C:\myapps\myservlets" on windows or "/myapps/myservlets" on

Now with that set up, calling your servlet that redirects to another
servlet might go something like this:

which might redirect to another servlet "MyRedirectResultServlet"

You'd have to make sure that the redirection goes to
"/servlet/MyRedirectResultServlet" in order for Tomcat to catch this
request as a request to this other servlet.

Did that answer the question or am I missing something?  Bottom line,
rename your context to something other than "servlet" to avoid


Tuesday, May 07, 2002, 10:08:41 AM, you wrote:

jw> I was hoping of something within the Tomcat configuration itself since we
jw> don't use an index.jsp file. To be more specific about my problem, Whenever
jw> a servlet calls another servlet in Tomcat it isn't intercepting the
jw> /servlet/ directive and replacing it with /spike/servlet/ which is what it
jw> should be doing. Perhaps I'm overlooking something obvious in the
jw> configuration that will do this, but I've tried putting a
jw> <Host name="DEFAULT" >
jw>     <Context path="/servlet"
jw>              docBase="/spike/servlet" />
jw>     </Host>

jw> Entry in the server.xml file, but that didn't seem to do it either...
jw> Someone smack me with a clue stick and tell me what I'm doing wrong?

jw> Josh
jw> ----- Original Message -----
jw> From: "Oki DZ" <>
jw> To: "Tomcat Users List" <>
jw> Sent: Monday, May 06, 2002 8:17 PM
jw> Subject: Re: Tomcat redirect

jw> On 05/07 04:19 joshua wentworth wrote:
>> I am trying to have Tomcat redirect certain requests to other applications
>> or other sites. But I can't find anything in the documentation or in any
jw> of
>> the messageboards about any kind of forward or redirect function in
jw> Tomcat.
>> Is there such a function, and if so where can I find documentation on it?

jw> You can use the following in my index.jsp, so that the main page will be
jw> redirected to some other location: <%
jw> response.sendRedirect(response.encodeRedirectURL("<new URL>"));

jw> Oki

jw> --
jw> To unsubscribe, e-mail:
jw> <>
jw> For additional commands, e-mail:
jw> <>

jw> --
jw> To unsubscribe, e-mail:   <>
jw> For additional commands, e-mail: <>

Best regards,

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

View raw message