modified so it will work on tomcat as well as GAE