This would be an odd way to architect a web app. Can you tell us in more detail what you're trying to accomplish (and why)?
In the meantime, you might want to check out OSGi, which has facilities to ads and remove features from applications based on the presence or absence of so-called bundles (jar files, essentially, with some special configuration).
Ping & DNS - updated with new look and Ping home screen widget
subject: Displaying features based on jars present in Tomcat application