JSON output from Vaadin

Hello everyone,

Is it possible to change the vaadin output from HTML to JSON?

I need to be able to open a specific url and then receive a JSON output.

Thank you very much for your help!


What is it you would like to achieve with this?
What JSON, for what purpose, representing what?
What will your application do with the JSON?

While the internal communication between the Vaadin server side and client side parts is currently implemented using JSON, it is meant for internal communication only and probably is not appropriate for your purposes. It might change between Vaadin versions, has a lot of component specific content and structure, many components only transmit the necessary/changed parts of data etc.

If what you want as JSON is not the Vaadin UI and its changes but just some other JSON you would generate, there should not be a problem - just generate it in a servlet (either a subclass of the Vaadin AbstractApplicationServlet, deciding on the content type based on the URL, or a separate servlet, mapped to a suitable path).

I think he would like to achieve is (this is only example) In mobile application you can receive JSON data from web page just to enter specific URL (this URL have to publish only JSON string)

Application would just put JSON string to specific URL and that other applications could get data from it

Use POHS Plain Old Http Servlets for it.
Or REST framework.

Can you provide any examples?

thank you


“The leading RESTful web framework for Java”

They have good documentation and examples.

Indeed. Vaadin provides no helps for building that kind of web services.

In case you’d insist keeping all your app logic inside a Vaadin applicaiton you
do it. Use a URIHandler registered into the main window.