As a general rule - never include any www.blahblah references in your images
(or any other resources for that matter)

I think the best way to do this is as follows

<img src="<%=request.getContextPath()%>/images/mygif.jpg"/>

The output will in your case be
<img src="/main/images/myimage.jpg"/>
and the image will be found and will display fine no matter what domain name
you host your site on


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Drew Kidder
Sent: Wednesday, 22 November 2000 2:32 AM
To: Orion-Interest
Subject: Virtual-directory vs. document-root


Heya folx....got another question for y'all...

I've got a site on a server, let's call it drew.serv1.com.  I use absolute
links to images there (i.e., <img src="/images/mygif.jpg">).  So the main
page could be accessed by http://drew.serv1.com/main/index.jsp and
everything works groovy.

Now, let's say that I have a proxy set up so that
http://www.drew.com/main/index.jsp should also work.  However, I find that
the absolute links are trying to be found based on a root of www.drew.com
as opposed to drew.serv1.com.

To remedy this problem, I can see adding http://drew.serv1.com as a preface
to all my image tags and anything else that is absolute (<img
src="http://drew.serv1.com/images/mygif.jpg">).  Time consuming and bad
programming.  So, I was reading about the <virtual-directory> and
<document-root> tags, and I was wondering which one of those would serve my
purpose? I was also thinking about the <virtual-host> tag as well, and was
wondering if I should add "www.drew.com" to the virtual-host tag of this
website?

And just for the sake of argument, let's just say that there's nothing I
can do about the DNSing or proxying at this point. :)

------
Andrew Kidder
L3 SW/Support Engineer
Tivoli Systems

512-436-4544
[EMAIL PROTECTED]
http://www.tivoli.com




Reply via email to