Saurabh
Saurabh

Reputation:

Communication between two applications running on two different versions of Tomcat

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>

Upvotes: 1

Views: 1307

Answers (4)

ZZ Coder
ZZ Coder

Reputation: 75496

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.

Upvotes: 0

Taylor Leese
Taylor Leese

Reputation: 52390

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.

Upvotes: 1

Jubal
Jubal

Reputation: 8727

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.

Upvotes: 0

psychoschlumpf
psychoschlumpf

Reputation: 3049

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

Upvotes: 0

Related Questions