Virtual Mappings

I’m new to Lucee (moved form CF) but struggle with directory mappings
I would like to include a few CSS or images with the following syntax:

<IMG SRC="img/nameofimage,jpg">

but that doesn’t work.
My project files (e.g. index.cfm) are all in c:\lucee\tomcat\webapps\root\ptr
and the images are in c:\lucee\tomcat\webapps\root\ptr\img

But the images or css files aren’t imported. Is there a specific settings I need to change to make this work?

There’s a lot of missing information here. Firstly, are you running your site through Tomcat directly or is it behind a web server like Apache or IIS? In either case, Lucee has no bearing on this whatever. If you’re hitting a web server which proxies CF requests to Lucee, then the web server is serving the images and you need to check that the web root of the virtual host is correct. If you’re hitting Tomcat directly on its HTTP listener, then it should boil down to what the context root of your Tomcat host is. But there’s a lot of possibilities there as well. How did you install Lucee? Is this a war deployment on a stock Tomcat instance, or a “traditional” Lucee installation that comes with Tomcat bundled?

In any of those cases, enable the access logs in your web server or Tomcat for clues and check for case sensitivity if on a *nix system.

I use the Lucee Tomcat server and so far it’s all local. With CF I used MS ISS and it all worked well, I just don’t understand how Tomcat interprets such path
Once I understand that I think everything will be fine

At the end of the day, Tomcat works the same way IIS does. It has a handler for static files that is based on the docroot of the context you’ve setup. Perhaps you can provide more information. In your OP you said the image “didn’t work”. What does that mean?? Is there an error? What about it isn’t working?

Hard to reply as I’m limited by the system (only 2 links etc…so I have to amend the links)

Image did’t work. The browser doesn’t show it. The first exampel beow shows it, the 2nd doesn’t. The broswer ony shows a placeholder
IMG SRC=“” WIDTH=“500” HEIGHT=“164” BORDER=“0” ALT=“Logo”>
IMG SRC="/img/logo_small.gif" WIDTH=“500” HEIGHT=“164” BORDER=“0” ALT=“Logo”>

I call the page: and it does what it is supposed to do (get data from, deserialized the JSON file and store all data into a MySQL database

Only the IMG SRC and link rel=“stylesheet” type="text/css"css/cssname.css… aren’t recognized by the browser

Webroot is: C:\lucee\tomcat\webapps\ROOT
import.cfm is stoed in C:\lucee\tomcat\webapps\ROOT\ptr\import.cfm
Image and CCS files are stored in C:\lucee\tomcat\webapps\ROOT\ptr\img and C:\lucee\tomcat\webapps\ROOT\ptr\css

I have tried to access them with ./img/filename and even full path IMG SRC=C:/lucee/tomcat/webapps/ROOT/ptr/img/imgname… but no luck

Ok, so firstly forget completely about the CFM file and the HTML image tag. Those are all distractions. Just test this by typing the URLs directly in your browser’s address bar.

The first exampel beow shows it, the 2nd doesn’t.

Do you realize that your two examples are not the same? The second one has a leading forward slash which means the canonical URL (unless you’ve overridden it with a base href) will be

It sounds like the first URL you posted in your first post should work, but there’s too much I don’t know, like what was in the browser’s address bar at the time. Relative image paths are going to be determined by what folder the browser thinks it served the current HTML/CF page from. Turn on your browser’s debugging toolset and look in the networking tab so you can see the actual full paths that your browser is trying to hit for the images. That should help you troubleshoot.

I would start by determining what the correct FULL URL is to the image, and then work backwards to determine what the correct relative URL would be. Or, you can just make all your image paths start with / but then you need to include everything after the host name.

I have tried to access them with ./img/filename

I don’t think that’s even valid. This isn’t bash and URLs have no concept of a dot to represent the current folder.

and even full path IMG SRC=C:/lucee/tomcat/webapps/ROOT/ptr/img/imgname…

That would never work. Think about it-- your browser has no idea what the local file system of your server is and for good reason. All the browser has is a host name and path.

Thanks. Let me use the browser debug mode tomorrow. The reason I use local full path is because server and browser are on the same system. It’s a test installation and I test my CF apps before I decide to move to Lucee but so far I only had to make very few adjustments (e.g. CFMenu isn’t supported) so it looks very good
Come back tomorrow with my IMG issue

It’s resolved, a strange one, case sensitive. I used some legacy directories which are in upper case (so <IMG SRC="IMG… but the HTML code had it lower case.

Under CF I used IIS which worked well but the Lucee’s tomcat is case sensitive

Time to switch from CF to LUcee now, thanks for your help

1 Like