This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Ahh, you forgot to look at the superclass ServletRequest and it's getScheme method which eliminates the need for the switch. It will also allow you to configure the server's ports without having to alter your code.
Also, getContextPath will provide the preceeding forward slash so you don't want to put it between getServerName and getContextPath
I agree with Bear though, it's much too long; begs for a custom tag. [ September 16, 2005: Message edited by: Ben Souther ]