tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Wingfield <jon.wingfi...@mkodo.com>
Subject Re: Rewriting URLs in Tomcat
Date Thu, 29 Jul 2004 10:26:18 GMT
sendRedirect(...) tells the browser to use a resource in a different 
location. That location can be same webapp, different webapp, different 
server.

forward(...) is for the same server only.
In context:
servletContext.getRequestDispatcher(path).forward(...);
Out of context:
servletContext.getContext(foreignContextName).getRequestDispatcher(path).forward(...);

For forwarding to a different context you have to have the relevant 
permissions or the servletContext.getContext(foreignContextName) call 
will return null. In tomcat the context doing the forwarding has to be 
marked as crossContext:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/context.html


Jon

PS the chained invocations above are illustrative only, not as I would 
normally code it ;)

Jacob Weber wrote:

> Tim Funk <funkman@joedog.org> wrote:
> 
>>At http://funkman.home.comcast.net/ I have a project called ServletUtils.
>>You can use either RedirectFilter or ForwardFilter. They both can use regex's.
> 
> 
> "Robert Harper" <robert@iat-cti.com> wrote:
> 
>>Have you tried the HttpServletResponse .sendRedirect( String url ) method?
> 
> 
> 
> Correct me if I'm wrong, but I think both of these approaches would 
> require the URL I'm requesting to be part of the same application as the 
> one I'm redirecting to. So, for example, I couldn't redirect from:
> 
> http://www.myserver.com/first_app/path
> 
> to
> 
> http://www.myserver.com/second_app/path
> 
> Or am I missing something? This is what I'm trying to do.
> Thanks,
> Jacob
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message