Actually, I'd probably write a custom tag to get all the goo of the page, but this is probably pretty close to how I'd do without writing my own tag.
I might probably also factor out pageContext.request to its own scoped variable since it is referenced so many times. [ September 16, 2005: Message edited by: Bear Bibeault ]
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 ]
This is server side code, it shouldn't make any difference what browser you're using. Look at the HTML source and see if it's being printed any differently.
If you mean that the <BASE tag isn't working as you expected, that's a different issue and has nothing to do with JSP.
The more common approach for J2EE apps is to make all links relative to the context root: