using the ServletContext to enable communication between Servlets within the same Application is quite nice and I wonder if there’s a comparable way to enable communication between servlets from different apps (which are deployed on the same Servlet-Container?
The background is that I’ve two applications which could be distributed to multiple servers. In that case they’re supposed to communicate via SOAP – but in case they’re both hosted in the same server (and Servlet-Container) I’d like to avoid the SOAP overhead and have direct communication.
Any suggestions?
Cheers
Such API existed in the first version of Servlet API. You could find other servlets from servlet context and call them. I doubt you could call servlets from other web applications.
Anyway this API was deprecated and is not supported more. The reason is that EJBs were introduced. Servlets play role of a web front-end only. They should not implement business logic and therefore should not communicate with each other.
The modern way to perform communication among different application is either using web services or EJB or if you are using Spring – their remote mechanisms or messaging.