create subdomains on the fly in a Java web app



Has anyone developed a web app that creates subdomain names on the
fly? For example a users of our web service can create a subdomain on
our main domain name, such as customersusername.ourdomainname.com?

I'm just wondering how this could be done.

Thanks
.