Each web application has one and only one ServletContext. There is no such thing as one ServletContext communicating with another ServletContext. This would be the same as one web app communicating with another web app. You can use the ServletContext to pass objects (and init parameters called context initialization parameters) between 2 Servlets that exist in the same web app.
If this were my issue and there were a lot of them, I would look at a product like Apache Axis to expose these methods as webservices.
If it were one or two, and they were fairly simple, I would probably just write a servlet that exposes the methods and then use either java.net.URLConnection or a library like Jakarta Commons httpclient to build the client on the other end.
I'm not an expert on JMS or RMI but you might want to look into those as well.
Originally posted by Raghavan Muthu: I know that webservice provides you the facility for the exposing the services outside.
Is it not possible to communicate within web applications without going for webservices or any other external features but using Servlet's features Ben?
I think it will make sense to use Servlet's features (like ServletContext etc) only for the interaction within the same web application. Is that right?
Just to confirm my thought on the same.
Yes, Tomcat (and most other servers, I assume) can be configured to allow some crossContext interaction. In this case, however, the original poster has already stated that the two applications are running on different instances of Tomcat. [ July 26, 2007: Message edited by: Ben Souther ]