You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Neha Munjal <ne...@gmail.com> on 2015/08/06 14:40:56 UTC

RequestDispatcher.forward between 2 virtual hosts defined in the same Tomcat container

Hi,

I would like to know if we can do servlet forwarding between 2 different
webapps deployed on 2 different virtual hosts configured in the same Tomcat
container.

So, I have configured 2 different virtual hosts in my Tomcat server.xml as
follows:
<Host name="firstservlet" appBase="firstservletapps"/>
 <Host name="secondservlet" appBase="secondservletapps"/>

and put the root.xml file for default webapps to:

$CATALINA_HOME/conf/Catalina/<virtualhost> directory.

servlet2 is deployed as a different war in the 2nd virtual host.

I notice that when I try to fetch the context of servlet2 from
Servlet1 to do a forward from Servlet1 to Servlet2, the loaded context
is null and so there is forwars. Please note that crossContext
attribute is set to true in the context.xml for the 1st war.

Also, noticed that in case I do not define any explicit virtual hosts
and deploy both the wars in the default host i.e localhost, the
forwarding works fine.

Can somebody please let me know if servlet.forward works with virtual hosts.

Any suggestions would be highly appreciated.


Thanks

Neha

Re: RequestDispatcher.forward between 2 virtual hosts defined in the same Tomcat container

Posted by Mark Thomas <ma...@apache.org>.
On 06/08/2015 13:40, Neha Munjal wrote:
> Hi,
> 
> I would like to know if we can do servlet forwarding between 2 different
> webapps deployed on 2 different virtual hosts configured in the same Tomcat
> container.

No.

Mark


> 
> So, I have configured 2 different virtual hosts in my Tomcat server.xml as
> follows:
> <Host name="firstservlet" appBase="firstservletapps"/>
>  <Host name="secondservlet" appBase="secondservletapps"/>
> 
> and put the root.xml file for default webapps to:
> 
> $CATALINA_HOME/conf/Catalina/<virtualhost> directory.
> 
> servlet2 is deployed as a different war in the 2nd virtual host.
> 
> I notice that when I try to fetch the context of servlet2 from
> Servlet1 to do a forward from Servlet1 to Servlet2, the loaded context
> is null and so there is forwars. Please note that crossContext
> attribute is set to true in the context.xml for the 1st war.
> 
> Also, noticed that in case I do not define any explicit virtual hosts
> and deploy both the wars in the default host i.e localhost, the
> forwarding works fine.
> 
> Can somebody please let me know if servlet.forward works with virtual hosts.
> 
> Any suggestions would be highly appreciated.
> 
> 
> Thanks
> 
> Neha
> 


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