I'm developing a web app. in Netbeans 3.6 using the inbuilt tomcat 5.x.
I'm having difficulty referring to other resources (pages/images/...) in the root of the context. I have directories in the root folder such as JSP,images,... to hold the different resources but want to be able to write a single non-relative link to access them.
i.e. in any webpage I want to write ...src="/images/myimage.gif"...
JSTL has the <c:url> tag. Struts has the <html:link page=""> construct. As far as automagically resolving the context, no such luck, but relative links work as long as you pay attention to what you're being relative to.
The "double-dot" convention means the same as it does for Unix/Linux and Windows relative file paths, except that the relativity is to webserver context paths. Of course, a context path isn't always translated a file path, which is where you can get bitten!
Customer surveys are for companies who didn't pay proper attention to begin with.
Is there an easy way of doing this without putting src="<%=request.getContextPath()%>/images/myimage.gif" ?
JSP 2.0 syntax is a little easier to read:
You could also investigate the use of the <base> HTML tag to set a relative path to your context root:
Personally I would avoid relative addressing using .. and the like -- it requires assumptions about the files relative position to each other, introducing uneccessary implicit knowledge binding, and makes it hard to rearrange the folder hierarchy.