War files don't communicate with one another. War files (Web Archives) are just a way of packaging a web application.
There are several ways that different web applications can communicate with one another.
There is also no such thing as a function in Java.
The servlet spec leaves some room for cross context communication but doesn't go into a lot of detail on how it should be implemented. Because of this you'll find inconsistent support and behavior between different containers and even different versions of the same container.
The getServletContext(contextname) method allows you to get a handle to other contexts runnning in the same container, from there, you should be able to work with objects from the other context. By default, Tomcat disallows this. To enable this, see 'crossContext' in this document: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
Because much of this is Tomcat specific, and doesn't necessarily apply to all containers, I'm going to move this from JSP to our Tomcat forum.