Hi,
Does anyone know of a way to get the context of a web app prior to compilation
of any jsps?
I've got a number of jsp's which all contain urls to static content (images
etc), the jsps themselves are often accessed from a number of different urls:
/jsp/myPage.jsp
/someUrl/actionservlet/someAction.do
this obviously rules out using relative urls to the static content. An
alternative would be to use urls based on the root, but this is a problem as I
want to deploy the web app to different contexts:
/test/
/dev/
/
etc.
An option would be to have a method which looks up the context and prefixes all
urls within the jsps with the appropriate context. This would be inefficient if
every jsp contains many pieces of content. What I'd like to do is to use a
public static final String which prefixes the urls. This value would then be
compiled into the jsp source just like any string literal - much more efficient.
To do this I need to have a way of guaranteeing that the variable is loaded
with the context prior to any jsp compilation.
Any ideas? Is there a better way?
Cheers
Nathan