Displaying Vaadin application/components in a JSP


I have a Web application based on the Struts2 framework and I am using JSPs for the view.
The test applications that I have created, to see what I can do using the Vaadin framework is great.
My test applications were standalone applications until now.

Now I need to integrate/display the components I have created in my existing JSPs. Does that work?

I experimented with the custom layouts, which works fine.
In that case, I had to use “html” files and integrate the Vaadin components using “

I have also tried it using the custom layout with the FileInputStream parameter and a JSP file, but it does not render the JSP. That means, the JSP file is loaded, but it’s treated as a standard HTML file.

What I want to do is, I want do render my JSPs (so all the Struts2 and JSTL tags should work) and display the Vaadin applications components.

Is this possible somehow?
Or do I misundestand something with the technik/architecture?

Hello again,

currently I’m thinking about my issue again.

I’m asking myself the questions and some of the answers:

  • Do I really need JSPs and dynamich content in these JSPs?
  • I think, we have to implement our functionality (that would be our Vaadin application) on the server, which is why we use Vaadin
  • My dynamic content is boundt to my components (ex. using Containers to tables, trees, …etc), so the logic is running in the Vaadin application on the server… Automatically via AJAX, thanks to Vaadin!
  • This means, I do NOT need JSPs. It is sufficient for my custom layout file(s) to be html files, which only define “placeholders” for my components (which are data containers)

Is this the correct way of thinking?
Or, does anybody see the need for JSPs and dynamic content in them?

Aladdin, yes, you cannot run JSP login in custom layouts as well as cannot access Vaadin components from JSP tags, e.g. mix JSP and Vaadin. However, you can embed Vaadin apps into your JSP pages - this is done the same way as embedding Vaadin apps to HTML page, which is described in the Book of Vaadin.

But that is useful only if you do not want to drop your existing JSP app and enhance it with some Vaadin UI (in form of stand-alone small apps embedded).


When I think about such small apps, I would embed these using IFrames. Is this the approach you prefer?
Or is there another way, how you would embed them?

You can also embed using

elements, however this restricts you for only one such app per page

Yes, using a div, I could embed one application.
I think, I want to embed severel small applications in one page. I will see, if I need that.

I also need to check, how I can make these different applications “speak” to eachother and share/send/receive data.
This also concerns the JSP page I think.

When I click a Link on the JSP page, it usually creates an AJAX-Request to the server and the response will be displayed in another part of the page (ex. in a div, no page-reload). Now this is all in the world of JSP.

What if I have my JSP page with this link and a Vaadin appliaction (or several ones)? When I click this link, it will create the AJAX-Request. The response will be displayed in the div (as usual) AND I want to send the response to my Vaadin application(s) as well.

Is this possible somehow? If yes, how?
If my scenario doesn’t make any sense, tell me that as well :wink:

Hmm, communicating between apps is an interesting thing :slight_smile:

as what comes to my mind immideately is that action from jsp page can send a JMS message which could be then received by a listeners (vaadin apps) and vice-verca - this, of ocurse, is true when you use JEE on server side.

I think, something similar could be arranged by using a singleton (for a webapp) class and it’s own message (event) queue.

This sounds interesting, and challenging.
It’s always good to have some ideas and different approaches to problems, doesn’t matter if they are easy or difficult.

Maybe I can give that a try sometime. :slight_smile:

Actually - you can use multiple Vaadin applications per page as long as they share common theme and widgetset.

If all the JSP:s and Vaadin applications are part of one web application (in same WAR), you can communicate directly on the server-side by calling methods. See
as a starting point for getting application reference.

Do you mean, by defining as many servlets as the number of applications and by configuring one different servlet-mapping for each application?


wow, did not think about this possibility ! :slight_smile:

And remember that there’s also the native JS API that you can use if you need to sync data to the client after some JSP Ajax-call:

javascript: vaadin.forceSync();

Don’t know what it does with multiple application instances, though. I guess they all should get synced.

Loading a Vaadin application into an IFrame works fine. And it looks great. :slight_smile:

However, using a div and loading the Vaadin application into that div, does not work.
All I get is a blank page. When I look at the page source of that blank page, it’s all there. (The sourcode of my JSP-Application)
I have also analyzed it using the FireBug plugin.

To achieve what I wanted, I did the following:

Now, when I click the link, FireBug shows that the Vaadin application is loading.
On the FireBug Console, I see some errors:

The question is, did I do something wrong, or does the loading into a div not work.

PS: This is just an information.
As I can use Vaadin applications in IFrames, everything is OK for me :wink: