Using Harbor
in a remote
Servlet Container
Pojo Application Server
Often you see questions like this on the Tomcat mailing lists, guys are trying to share stuff between servlets, and there are lots of ways to do it, but choices are always good.
For example if servlets are sitting in the same web-app, shared objects can be passed through the context.
One can make a custom JNDI object on the server to share an object across all web-apps, one can make a singleton (true singleton) and jam that in a common library. One can make one servlet the thing that does it, and dispatch requests off to that servlet.
Its a wonderful environment, but sometimes things are not even on the same machine, or not in the same Tomcat, and then normally someone says, get a Super-Can (an EJB application server), and a lot of the time there is no reply, probably because the TC user just had a heart attack.So we want to show you something that actually you should have guessed already.
Lets just say you have a web site at every branch office, because its a nice way to distribute load and share bandwidth, but there is something that you would like to code centrally, maybe its the dB pool, maybe monthly reports, who knows.
What this little example shows you, in much the same way as the test code, in fact its using the test classes just for this demo... is how to use your Harbor no matter where it is, in servlets, no matter where they are.
Harbor Symbol