You might also want to look at the Administrator application.
It doesn't ship with the more recent versions and I'm not sure if it's even supported any more but I know it does allow you to create, and configure things like data sources, and users while Tomcat is running.
The source to this application might get you off to a good start.
You can download the Administrator application for Tomcat 5.5 from here:
http://tomcat.apache.org/download-55.cgi [ June 28, 2008: Message edited by: Ben Souther ]