Serving images

Hi, I’m new to Vaadin and I’m currently working on migrating one of my projects from GWT to this wonderful platform.

Now to my question, before I’ve used a separate servlet to serve images loaded from a database. Which file was served depended on the uri/path. Kind of a virtual file system if you’d like.

Is there any way of doing this within the scope of my Vaadin application, or is a separate servlet the way to go?

I hope my question is clear enough, thanks.

Hi Kristoffer,

in Vaadin you can use Embedded component to represent an image. It uses the Resource interface for the image data, so you then any of existing implementations of it ( Theme, Url, Filesystem ) or write your own which is trivial task.

You can check the following
Sampler section
- note the samples for various type of resources in the black panel at right.


Thanks for your answer! But what I was looking for was something like this:

The user points his browser to “/myvaadingapp/images/myimage.jpg” and my application responds with an image file, which I fetch from the database.

I managed to implement this through URIHandlers which worked great.