Hello joshua, Well, take a look at the form action:
action="/servlet/CatalogServlet" This isn't even a servlet to servlet call. This is a browser to servlet call. On top of that, you are telling the form to be sumbmitted to http://our.server.com:8080/servlet/CatalogServlet This tells Tomcat to look in the ROOT context and find a servlet called "CatalogServlet". However, you want to look in the "spike" context. Just change your action to the following: Assuming you are at a web address that looks like: http://our.server.com/spike/servlet/SomeServlet action="CatalogServlet" will be translated by the browser as a request to: http://our.server.com/spike/servlet/CatalogServlet or if you don't want to count on being in the /spike/servlet path already like above, then provide a hard path off the root of the web server: action="/spike/servlet/CatalogServlet" Which translates to the following no matter what your current URL is: http://our.server.com/spike/servlet/CatalogServlet If you are wondering how to dynamically write this link in your servlet, just do: req.getServletContext() + "/servlet/CatalogServlet" That will translate to: "/spike/servlet/CatalogServet" which is what you want. Note, it also works if you are using the ROOT context since req.getServletContext() will return "/" in that case. Does that help? Jake Tuesday, May 07, 2002, 11:16:35 AM, you wrote: jw> Yeah, I figured that out a bit later. The problem seems to be that Tomcat is jw> just ignoring the call to /servlet/Whatever. jw> The situation is like this, I'm trying to get as specific as possible now. jw> The code looks like this: jw> <form name=insertForm action=/servlet/CatalogServlet onSubmit="return validate()">> jw> And if someone clicks on that button they get a 404 and Tomcat returns the jw> error that it can't find /servlet/CatalogServlet. This exists without any jw> <context> stuff setup in server.xml. The problem is that in the original jw> call to the original servlet we have apache redirecting the request to jw> http://our.server.com:8080/spike/servlet/OurServlet and when OurServlet jw> calls OtherServlet via the code above it tries to locate it on jw> http://our.server.com:8080/servlet/OtherServlet and that doesn't work. It jw> has to have the /spike/ in there. So... Any idea how I can do that? One of jw> the issues is that I can't change the code in the servlet itself (Otherwise jw> fixing this would be trivial). jw> Josh jw> ----- Original Message ----- jw> From: "Jacob Kjome" <[EMAIL PROTECTED]> jw> To: "Tomcat Users List" <[EMAIL PROTECTED]> jw> Sent: Tuesday, May 07, 2002 12:01 PM jw> Subject: Re[2]: Tomcat redirect >> 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: >> >> http://myserver.com/servlet/ >> >> 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 jw> 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 http://myserver.com/myservlets 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 >> Unix. >> >> Now with that set up, calling your servlet that redirects to another >> servlet might go something like this: >> >> http://myserver.com/myservlets/servlet/MyRedirectServlet >> >> 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 >> confusion. >> >> Jake >> >> Tuesday, May 07, 2002, 10:08:41 AM, you wrote: >> >> jw> I was hoping of something within the Tomcat configuration itself since jw> we >> jw> don't use an index.jsp file. To be more specific about my problem, jw> 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 jw> 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" <[EMAIL PROTECTED]> >> jw> To: "Tomcat Users List" <[EMAIL PROTECTED]> >> 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 jw> applications >> >> or other sites. But I can't find anything in the documentation or in jw> 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 jw> it? >> >> jw> You can use the following in my index.jsp, so that the main page will jw> be >> jw> redirected to some other location: <% >> jw> response.sendRedirect(response.encodeRedirectURL("<new URL>")); >> %>> >> >> jw> Oki >> >> >> >> jw> -- >> jw> To unsubscribe, e-mail: >> jw> <mailto:[EMAIL PROTECTED]> >> jw> For additional commands, e-mail: >> jw> <mailto:[EMAIL PROTECTED]> >> >> >> jw> -- >> jw> To unsubscribe, e-mail: jw> <mailto:[EMAIL PROTECTED]> >> jw> For additional commands, e-mail: jw> <mailto:[EMAIL PROTECTED]> >> >> >> >> -- >> Best regards, >> Jacob mailto:[EMAIL PROTECTED] >> >> >> -- >> To unsubscribe, e-mail: jw> <mailto:[EMAIL PROTECTED]> >> For additional commands, e-mail: jw> <mailto:[EMAIL PROTECTED]> >> jw> -- jw> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> jw> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- Best regards, Jacob mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>