Is placed within the sub domain host element. I've read however that, that can cause problems and that context elements should be kept out of the server.xml and instead be defined in the context.xml.
Right now both the sub domain and the domain will map to the ROOT folder. So at this stage I think I could use a filter to forward according to the sub domain or I could do something to the context.xml.
Could someone please suggest the correct way of implementing this and if I need to use the context.xml what should the context element look like?
Actually, "*.domain.com" wouldn't represent wildcard sub-domains, it would represent wildcard hostnames. A fully-qualified domain name (FQDN) includes the hostname as its first element. A true wildcard subdomain name would be "*.*.domain.com" or "www.*.domain.com". The domain name can never be a wildcard.
In order to implement such a scheme, however, you'd need a specialized Domain Name Server setup for your authoritative name servers. DNS is basically supposed to be a "telephone directory" where, given a FQDN, the directory is consulted, and (assuming a match), a corresponding IP address is returned. What you'd need would be a DNS server that - instead of serving as a database - cooked up IP addresses on the fly. Which wouldn't be that hard if you only have one server, but I happen to have more than physical host on my domain, so the logic would be more complicated than just "match anything/return same thing" in my case.
You also probably won't make many friends using this scheme, since for performance reasons, DNS entried are usually cached at various levels between client and server, and caching and dynamic DNS are somewhat opposed.
The second part of your question can be resolved in several ways. One way is to front Tomcat with a server that can translate URLs such as Apache. Another way is to deploy your webapp at the context root for the Tomcat Host.
An IDE is no substitute for an Intelligent Developer.