I don't like HTML base tags, generally, because they make debugging confusing and they specify something that has no value (doesn't help, but reduces flexibility, and might break stuff). I have heard some justifications for their use, but I've written thousands of web pages and never needed one. I tend to prefer to use context-relative URLs for everything that is within my site or webapp. I do take great care to make sure that my webapps could be deployed with any context path (/myapp or /myapp-1.2 or /myapp-debugging-something-old-without-disturbing-my-main-deployment). If you start out with the idea that your app may be deployed with any context path, it doesn't take much to keep everything working correctly. I know that different people on my project team deploy the app with different context paths, and I really like that since it continuously tests that we are doing things properly.
Mozilla & Netscape's Page Info feature is useful for examining all the image references in a rendered page if you suspect a problem. Those browsers also have a more visible indicator that an image reference is broken than IE, which is also nice. I really like the struts tag libraries in that they allow you to specify a context-relative path to resources using the page attribute. I use these all the time. For your image tag, you could do something like this: <html:img page="/images/myimage.jpg" /> Another alternative without using a tag lib: <img src="<%=request.getContextPath()%>/images/myimage.jpg"> Both of these will render like this (assuming your app's context path is /webapp): <img src="/webapp/images/myimage.jpg"> -Max ----- Original Message ----- From: "Bryce Fischer" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 24, 2003 5:16 PM Subject: <html:base /> Question > This is probably less a Struts question than it is an HTML question, but > I figured most here have dealt with this issue. > > I'm a little confused by the <html:base /> tag. Lets say we have the > following directory structure WITHIN our webapp: > > webapp > - images > - myimage.jpg > - scripts > - WEB-INF > - pages > - test.jsp > > Ok. Now I've got a jsp page that's in the webapp/WEB-INF/pages directory. > In that webapp, I've got the <html:base /> tag declared in the header. > Now, when I view source on my test.jsp page, I see this: > > <base href="http://localhost/webapp/WEB-INF/pages/test.jsp"/> > > Now, on that page, I want to reference an image in > webapp/images/myimage.jpg. I can get there by using: > > href="../../images/myimage.jpg" > > But I'd rather not. Is there a way to get to the root of the webapp? > I've tried: > > /images/myimage.jpg > > And that doesn't seem to work. > > -- > > Bryce Fischer <[EMAIL PROTECTED]> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

