Remember that images are loaded by the browser, not Maverick, so
pathnames must be relative to what the browser thinks the root is.

The browser is getting an html page by accessing something like
/yourCmd.m.
If the html page has an img reference to ../images/blah.gif, then the
browser will try to load /../images/blah.gif.

This is a bit of a tricky problem that applies to any MVC webapp
framework.  It gets even trickier if you try to group your commands with
extra path at the beginning.  Two approaches:

Put relative paths in all your templates, "images/blah.gif".  This will
look kinda funny with your JSPs in a jsp/ directory, and will cause
trouble if you use html editors.  You can solve this with a symbolic
link jsp/images/ to ../images, or by putting your JSPs at the top level.

Put absolute paths in all your templates, "/images/blah.gif".  This will
break editors and cause additional trouble if you are mounting your
webapp anywhere besides the root of the appserver (ie,
http://yourhost/foo/).  You can get around the latter problem in JSP by
crafting your image tags like this:  <img src="<%=
request.getContextPath() %>/images/blah.gif"/> but that is insanely
ugly.

This part of the servlet spec isn't very well thought out, IMHO.

I advise using relative paths everywhere.

Jeff

> -----Original Message-----
> From: Ed Thompson [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 06, 2003 12:25 PM
> To: [EMAIL PROTECTED]
> Subject: [Mav-user] relative paths under Maverick...
> 
> I started playing wqith maverick under windows 98.  When I first wrote
> the web app (pre-Maverick)with the following directory struture:
> 
> root/
> |---jsp/
> |---images/
> |---styles/
> 
> I referenced the images from my jsp (under the jsp directory) like
this:
> 
> ../images/imagename.gif
> 
> When I refactored the app under win98 Maverick, I had to chnage the
> refernce:
> 
> images/imagename.gif
> 
> I assumed that is becuase Maverick somehow chnaged the relative path
of
> my jsp to the root?
> 
> But then I moved th app to linux, and now even under Maverick I have
to
> chnage the reference back to:
> 
> ../images/imagename.gif
> 
> What am I missing here?
> 
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> [INVALID FOOTER]



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
[INVALID FOOTER]

Reply via email to