Why can't we get rid of JNLP @codebase?
Java Web Start demands that the JNLP file contains the codebase attribute on the root <jnlp> tag, but this is really problematic.
The reason this is problematic is mainly because of the difficulty for a web application to know its own URL. Think about a web app like Hudson, which can be deployed anywhere, and thus doesn't have any a'priori knowledge of its URL. The closest it gets is the Host header and request URI line, but even this isn't necessarily what the browser has sent to you, for example if a reverse proxy is involved (and this is a very common set up.)
So I was thinking about filing a bug, and started to dig bit deeper into understanding why the codebase attribute is necessary. The first authoritative information I found was "Codebase Determination for JavaSE 6u10", and in it it simply says this is so "for technical reasons."
I eventually found out the root cause in the bug parade:
The Browser downloads the jnlp file
into a temp directory on the client. The browser then launches Java Web Start
with that file as an arg. Java Web Start has no way of knowing where that file
was downloaded from.
This also reminds me of another annoying usability issue with Java Web Start, namely it clutters your desktops with *.jnlp files.
It's bit hard to believe that there's no way to retrieve the original URL from the browser — I can see why it can't be done if JWS depends on the "associated application" mechanism, but shouldn't there be more/better ways to integrate with browsers? After all, this seems like a fairly generally useful capability.
In any case, until then, the only solution is for the application to ask the user to enter the URL. Bummer.