M
markspace
Hi all,
I'm delving more heavily into JSP/Servlets and JSF at the moment. I've
found something that looks like a questionable design issue by the JEE
folks at Sun (now Oracle, of course) and I'd like to pick your brains
about how you might deal with it.
Basically, when developing a JEE web app, the application name gets
inserted into every URL and associated path. If my app is named
TechDarwinia, for example, then all URLS look like this:
http://localhost:8080/TechDarwinia/
http://localhost:8080/TechDarwinia/faces/readPost.xhtml
http://localhost:8080/TechDarwinia/rsrc/css/style.css
The problem is of course that the web app could be renamed anything by
the deployer/sysop, and I've got strings hard coded to that app name
TechDarwinia.
So how do folks write their apps so that they can handle being deployed
under different names?
I can think of a couple of solutions, but they don't seem good.
One solution might be to make the app name an application parameter.
This would mean that everywhere I have to insert some sort of EL
variable, or equivalent, and the app takes extra time replacing the
parameter constantly. Also, the installer has one extra parameter to
configure, and I'd like to avoid that.
The app parameter method fails where URLs are required but it's not
possible to invoke Java. For example, in a static resource like CSS:
body {
background:url(/TechDarwinia/rsrc/img/bbg.jpg) left top repeat;
....
Another solution might be, and I haven't investigated this fully, to use
another agent, like Apache, that has the ability to rewrite URLs before
they are presented to the container, inserting the app name wherever it
is lacking. This also requires extra CPU overhead for each request,
(but only one string swap per request, where the app parameter method
may require many EL substitutions), and also extra work by an installer.
This could be very complicated though, as using more than one app at a
time might make the re-write rules overly complicated.
Both cases run the risk of two application names colliding, as there's
no real convention regarding name we apps.
So, has anyone also encountered issues like this? And how did you fix them?
Thanks all!
I'm delving more heavily into JSP/Servlets and JSF at the moment. I've
found something that looks like a questionable design issue by the JEE
folks at Sun (now Oracle, of course) and I'd like to pick your brains
about how you might deal with it.
Basically, when developing a JEE web app, the application name gets
inserted into every URL and associated path. If my app is named
TechDarwinia, for example, then all URLS look like this:
http://localhost:8080/TechDarwinia/
http://localhost:8080/TechDarwinia/faces/readPost.xhtml
http://localhost:8080/TechDarwinia/rsrc/css/style.css
The problem is of course that the web app could be renamed anything by
the deployer/sysop, and I've got strings hard coded to that app name
TechDarwinia.
So how do folks write their apps so that they can handle being deployed
under different names?
I can think of a couple of solutions, but they don't seem good.
One solution might be to make the app name an application parameter.
This would mean that everywhere I have to insert some sort of EL
variable, or equivalent, and the app takes extra time replacing the
parameter constantly. Also, the installer has one extra parameter to
configure, and I'd like to avoid that.
The app parameter method fails where URLs are required but it's not
possible to invoke Java. For example, in a static resource like CSS:
body {
background:url(/TechDarwinia/rsrc/img/bbg.jpg) left top repeat;
....
Another solution might be, and I haven't investigated this fully, to use
another agent, like Apache, that has the ability to rewrite URLs before
they are presented to the container, inserting the app name wherever it
is lacking. This also requires extra CPU overhead for each request,
(but only one string swap per request, where the app parameter method
may require many EL substitutions), and also extra work by an installer.
This could be very complicated though, as using more than one app at a
time might make the re-write rules overly complicated.
Both cases run the risk of two application names colliding, as there's
no real convention regarding name we apps.
So, has anyone also encountered issues like this? And how did you fix them?
Thanks all!