I’m reading the Vaadin book and trying to understand how resources work.
From what i could understand, ClassResource load resources in the classpath.
FileResource is the better option for “full path” resources.
And ThemeResource for resources related to a theme.
So, given these options which is the best for load resources in webapp folder? Is there another?
You may ask “why webapp folder”? Because I think it is the most intuitive place for images and other resources. At least it was where I usually put my resources in other projects.
PS: I mean webapp in maven (src/main/webapp) which is the same of WebContents in Eclipse webapp project.
If you want to put your images in your webapp folder it’s probably easiest to use ExternalResource and give it the URL to your image, which will be in the form http://server/context/path/to/image.png
It’s usually a bigger pain to use the ClassResource or FileResource. ThemeResource is very easy to use, but it requires you to duplicate images if you happen to switch between two different themes.
I have managed to find that the VAADIN folder (http://localhost:8080/context/VAADIN/image.png) is exposed to the “outside world”, but I’m not sure if I’m doing the right thing since I’m not putting the files inside a specific theme.
This makes tomcat (or whatever servlet container you’re using) serve the specified url-pattern statically instead of going through the vaadin application that is mapped to /* by default.
Thanks a lot. This actually has moved it somewhere, now I get the Http 404 Resourcce not found error when I hit the URL http://localhost:8080/Application/images/Image.png inspite of the fact that the image is present in the webapps folder of tomcat - webapps/Application/images.