I'm learning
Java by trial by fire. I've just completed my first site (on
Tomcat running under W2k Pro) and its based off the dispatcher->controller->template recipe. The first site has several classes I would like to use in site 2 (the dispatcher itself, the database query tools, my templating class, etc). Then there's several classes that I feel I'll need in both sites, but will need to be modified slightly (I have a displaynav class which manages building a site's nav menus - well, right now just site 1's nav menus).
My first thought process was to copy the WEB-INF/classes/* data to site two and rename the packages and directory name (to match the new package name). I wasn't a fan of this idea because now there's two copies of each class floating around. I haven't been able to get any new classes for site 2 to use any of the copied over classes (error was something like cannot reference class - class was being specified with the full package name for site 2).
So my 2nd thought was to put the classes that should be available to all the sites on this server in directory and put that directory in the CLASSPATH. I haven't been able to get this to work.
Is it possible to put some of these classes in one spot and be able to access them from sites that are on the same server, but in different directories? From the looks of it, it appears Java is good at doing this, but I'm not sure how I need to tweak the web.xml, server.xml, and/or the CLASSPATH. Is it possible to have 1 dispatcher saved in one directory and have multiple sites call it?
If anyone has links to any online documentation on this, it would be very helpful. If anyone has a better approach to doing this, I'd be excited to hear it. Thanks!