Static HTML page

Hi I have to present some fixed HTMLs inside a new window.

But I cannot get them to work.

Where should I put the html files ? I have them now in VAADIN root folder, because WEB-INF was not working, and VAADIN is not working too.

I was trying to get them using this deprecated method but I don’t like this idea : getRelativeLocation() and it’s not working anyway.

I always get a file not found.

Is it possible to do something like this

TARGET = new ExternalResource(“…/rwhowto.html”);


and them use it in a Link obj ? I can’t make it work… and I can`t use vaadin windows have to be the HTML.

Is it possible ?


This depends on how you are doing it. I would recommend using a
for your purpose. CustomLayouts can be used as static HTML pages, but you can easily also attach some Vaadin components to the div:s.

Then create your own theme, use it, and add your html pages here:


There are also a few other ways. For instance adding the html to a Label, or inside an

Inside the WEB-INF/ folder, you should only put data that is meant to be invisible for the users. Adding your pages here will certainly not show up at your browser :slight_smile:


Some more options:

  1. If you can browse to the file with your browser, e.g http://localhost:8080/mypage.html, then you can use ExternalResource with that URL.
    (you’ll have to set up your server so that you can server static files (so that the Vaadin servlet does not ‘eat’ those requests.)

  2. You should also be able to place the file in your theme (under VAADIN/themes//) and use a ThemeResource().

  3. You can also place your html ‘next to’ your class files, and use a ClassResource, which uses the classloader to load the file.

…there are more ways to do this, but let’s start with these :wink:

Best Regards,

Thank both of you !

I used the theme approach because it was faster for me as I am already using a custom theme.

So I moved my page to the theme root folder


and pointed a theme resource and set the resource to the link to it like this

    ThemeResource file = new ThemeResource("rwhowto.html");
    howLink = new Link();      

Now I get a new window, with my HTML inside ! great ! :smiley:

Loving this framework…

Now problem number 2

With if I change my page and restart the server it keeps the old one ? and how can it happen as I restarted the server…

the only way to update my html is changing it’s name. even with ?restartapplication it still provide me the old version.

It’s probably cached in the browser. Why, and ow to fix this depends a little bit on how your server is set up, but it’s possible that ThemeResource is not your best choice if you plan to update the file regularly.

Some possibilities that spring to mind:

  • You could try serving the VAADIN directory statically/directly (as opposed to serving it via the Vaadin servlet). This is generally a good idea performance wise, and your server might be better at detecting changed files.

  • You could use something other than ThemeResource, for instance all ApplicationResources have a setCacheTime() method.

(- I’m not sure this works, but you could try to append a unique parameter to the name when the html changes; “mypage.html?123”)

Best Regards,