You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ron Crayton <rj...@yahoo.com> on 2005/04/11 20:35:55 UTC
RequestDispatcher.forward() to doc located on HTTP Server
Is it possible to use Request.forward() to forward a request to an html document located on an HTTP Server?
I'm using Tomcat 5.5.7 and Apache 2.0.
I have a document setting in the htdocs folder of Apache 2.0 that I'm trying to forward to from an application deployed in Tomcat 5.5.7.
I have this context in my server.xml file:
<Context path="/LoginApp" docBase="LoginApp" debug="0" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="LoginApp." suffix=".log" timestamp="true"/>
</Context>
I have this code in my app:
ServletContext context = getServletConfig().getServletContext();
String uri = request.getQueryString();
ServletContext foreignContext = context.getContext("/");
RequestDispatcher requestDispatcher = foreignContext.getRequestDispatcher(uri);
requestDispatcher.forward(request, response);
The uri comes from the query string of the original request.
When the code runs it says that the requested resource is not available - Error 404.
Am I trying to do something that's impossible?
Please help.
---------------------------------
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
Re: RequestDispatcher.forward() to doc located on HTTP Server
Posted by Mark Thomas <ma...@apache.org>.
You might have better luck using a redirect. This should cause the
client to request the alternate resource which Apache would then serve.
Mark
Ron Crayton wrote:
> Is it possible to use Request.forward() to forward a request to an html document located on an HTTP Server?
>
> I'm using Tomcat 5.5.7 and Apache 2.0.
>
> I have a document setting in the htdocs folder of Apache 2.0 that I'm trying to forward to from an application deployed in Tomcat 5.5.7.
>
> I have this context in my server.xml file:
>
> <Context path="/LoginApp" docBase="LoginApp" debug="0" reloadable="true" crossContext="true">
> <Logger className="org.apache.catalina.logger.FileLogger" prefix="LoginApp." suffix=".log" timestamp="true"/>
> </Context>
>
> I have this code in my app:
>
> ServletContext context = getServletConfig().getServletContext();
> String uri = request.getQueryString();
>
> ServletContext foreignContext = context.getContext("/");
> RequestDispatcher requestDispatcher = foreignContext.getRequestDispatcher(uri);
> requestDispatcher.forward(request, response);
>
> The uri comes from the query string of the original request.
> When the code runs it says that the requested resource is not available - Error 404.
>
> Am I trying to do something that's impossible?
>
> Please help.
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org