tags:

views:

387

answers:

4

I have two web application running on two different versions of Tomcat. App1 is on Tomcat5 and App2 is on Tomcat6. Is there any way, so that I can make a communication among these two. For example - If there is a JavaScript file in App2/js/mycode.js, then I would like to refer this from App1/page/mypage.jsp. For both applications I have defined context as -

App1.xml (Tomcat5\conf\Catalina\localhost)

<Context path="/App1" docBase="C:/eclipse/workspace/App1" debug="0">
</Context>

App2.xml (Tomcat6\conf\Catalina\localhost)

<Context path="/App2" docBase="C:/eclipse/workspace/App2" debug="0">
</Context>
A: 

If you are running under UNIX, you could symlink the javascript file from one app to the other.

psychoschlumpf
I am using Windows XP.
A: 

If you're using a proxy or ajp mounting the two apps behind an apcache server, as long as you keep the fqdns are the same to the clients browser it should be fine.

jskaggz
Hard to type on stckoverflow using iPhone :-P
jskaggz
+1  A: 

If you place an Apache server in front of the Tomcat instances you can use mod_proxy and mod_rewrite to achieve common URL's for files hosted on different servers.

Taylor Leese
+1 Consider mod_jk as well.
mrrtnn
A: 

You don't really need two servers to talk, you can just tell browser to get the Javascript from the other instance. For example, you can add this in App1/page/mypage.jsp,

<script language="javascript" type="text/javascript" src="../../App2/js/mycode.js"></script>

Notice how the relative URL is used in src. This assumes you run both instances behind same front-end (Apache or a switch). If you have to run them on different host or port, you just need to use absolute URL.

Another suggestion is to use a symbolic link for shared directories. This works for me on Unix but I am not sure if it works with Windows short-cut.

ZZ Coder