2
votes

I have one webserver with 2 instances of tomcat running. On each tomcat instance I have multiple web apps or web services.

What is the best way to call a function (or trigger some event with parameters) from a webapp of the first tomcat server on a webapp running on the second tomcat server. If it's for example a call using a url with parameters then this call should be secure and not accessible from outside the server.

I've read something about getting the servlet context but is this possible on different tomcat instances? Im thinking that this is only possible with webapps running in the same instance.

I dont want to use CORBA, RMI or SOAP because this is a bit oversized for my problem ... that is what Im thinking :)

Code examples are welcome. Thank you!

3

3 Answers

0
votes

The ServletContext is only valid within the same container and can't be shared between two JVMs. The simplest method to do what you're asking is to just use some variety of RPC between the two containers, and RMI doesn't seem like particular overkill. The other usual approach would be a simple HTTP Web service (note the lowercase "s") that invokes your logic in the receiving container.

0
votes

Spring's HTTPInvoker is great for this. You can use a Java interface, and your code on each instance doesn't need to know the call is remote - it just calls Java methods.

For security, you can use the Sun HTTP server on a different port (instead of using a servlet within Tomcat) and listen only on localhost.

Have a look here

http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/remoting.html#remoting-httpinvoker

0
votes

Use Simple REST services , not that much secured .