0

Using smartgwt 2.4.0 i have created a war. Running on jetty everything works fine. But once I deploy my war on tomcat, everything works fine except for my images; like the logo.

My smartgwt is mavenized, I dont know if this causes the problem. Anyways my path to my images is: src/main/webapp/images

So bassicly in my webapp I've created a directory images. When I check my war, this directory exists, altho tomcat seems to refuse to load my images.

In my java code I set a certain image like so (again on jetty it works fine, except for tomcat):

Img logo = new Img("/images/logo.png", 1000, 100);
Fico
  • 619
  • 8
  • 12
  • are you talking about the embedded Jetty on eclipse ? Development mode ? Production mode ? Did you test multiple versions of tomcat ? – Jean-Michel Garcia Jun 27 '12 at 06:54
  • Yes I was talking about embedded eclipse. When deploying the application it was on apache-tomcat-7.0.22 – Fico Oct 30 '12 at 09:13

1 Answers1

2

Use server-relative URLs to all external resources like images, stylesheets, script files, etc.

Server-relative URLs begin with the context path to the web application. If your web application is mapped to context path /mywebapp and your images are in the folder images at the root of the context path, the correct URL to logo.png would be:

/mywebapp/images/logo.png

Having said that, use Apache to serve static content, requiring Tomcat to serve only dynamic content.

Community
  • 1
  • 1
nohup
  • 517
  • 3
  • 4
  • Really bad advice.. mywebapp can change depending on the environment you are. You should use completely relative paths, like "images/logo.png". – Bruno Medeiros Sep 16 '13 at 21:27