{"id":37202,"date":"2016-05-17T15:00:32","date_gmt":"2016-05-17T12:00:32","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=37202"},"modified":"2019-04-09T13:11:23","modified_gmt":"2019-04-09T10:11:23","slug":"vaadin-rest-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/","title":{"rendered":"Vaadin Rest Example"},"content":{"rendered":"<p>REST stands for Representational State Transfer. Created by Roy Fielding in the year 2000, is a communication protocol where everything is a resource. REST principal characteristics are: client-server, stateless, cache-able, layered and uniform interface to access resources.<\/p>\n<p>Resources are accessed using a stateless protocol like HTTP. REST allows text, XML, JSON and other resources. PUT, GET, POST and DELETE methods are implemented in the REST architecture. Java defines REST using the JAX-RS Specification (JSR) 311. JAX-RS is implemented using Jersey.<br \/>\n&nbsp;<br \/>\n&nbsp;\n<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#tools\">1. The tools<\/a><\/dt>\n<dt><a href=\"#introduction\">2. Introduction<\/a><\/dt>\n<dt><a href=\"#prerequisites\">3. Prerequisites<\/a><\/dt>\n<dt><a href=\"#setupserver\">4. Set up the server project<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#downloadjersey\">4.1 Download Jersey<\/a><\/dt>\n<dt><a href=\"#createserver\">4.2 Create the server project<\/a><\/dt>\n<dt><a href=\"#copylibs\">4.3 Copy Jersey Files<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#codingserver\">5. Coding the server<\/a><\/dt>\n<dt><a href=\"#serverwebxml\">6. The server web.xml<\/a><\/dt>\n<dt><a href=\"#clientproject\">7. Create the client project<\/a><\/dt>\n<dt><a href=\"#codingclient\">8. Coding the client project<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#clientclass\">8.1 Client Class to access the server<\/a><\/dt>\n<dt><a href=\"#vaadinui\">8.2 Vaadin UI<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#completesource\">9. The complete source code<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#serversource\">9.1 The server source code<\/a><\/dt>\n<dt><a href=\"#clientsource\">9.2 The client Source Code<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#runningexample\">10. Running the example<\/a><\/dt>\n<dt><a href=\"#results\">11. Results<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#getresponse\">11.1 Get the response<\/a><\/dt>\n<dt><a href=\"#gettext\">11.2 Get the plain text<\/a><\/dt>\n<dt><a href=\"#getxml\">11.3 Get the XML<\/a><\/dt>\n<dt><a href=\"#getjson\">11.4 Get the JSON<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#downloadsource\">12. Download the Source Code<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2><a name=\"tools\"><\/a>1. The tools<\/h2>\n<ul>\n<li>Java JDK 8<\/li>\n<li>Latest Eclipse Mars<\/li>\n<li>Vaadin 7.6.5<\/li>\n<li>Tomcat Server 8<\/li>\n<li>Latest Jersey<\/li>\n<\/ul>\n<h2><a name=\"introduction\"><\/a>2. Introduction<\/h2>\n<p>In this example we are going to create a server using Jersey with text, XML and JSON resources and access these resources from Vaadin, to show it on the user interface. First we are going to create the server and run it. Next we are going to create the Vaadin client and consume the resources on the server.<\/p>\n<h2><a name=\"prerequisites\"><\/a>3. Prerequisites<\/h2>\n<ul>\n<li>JDK installed<\/li>\n<li>Eclipse Mars installed and working<\/li>\n<li>Vaadin 7.6.5 plug-in installed<\/li>\n<li>Tomcat 8 installed and running<\/li>\n<\/ul>\n<h2><a name=\"setupserver\"><\/a>4. Set up the server project<\/h2>\n<h3><a name=\"downloadjersey\"><\/a>4.1 Download Jersey<\/h3>\n<p>Download latest Jersey library from <a href=\"https:\/\/jersey.java.net\/download.html\">Download Jersey<\/a>, uncompress the zip file and save it for later.<\/p>\n<p><figure id=\"attachment_37204\" aria-describedby=\"caption-attachment-37204\" style=\"width: 578px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/01-Download-Jersey.png\"><img decoding=\"async\" class=\"wp-image-37204 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/01-Download-Jersey.png\" alt=\"Figure 1: Download Jersey\" width=\"578\" height=\"508\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/01-Download-Jersey.png 578w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/01-Download-Jersey-300x264.png 300w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/><\/a><figcaption id=\"caption-attachment-37204\" class=\"wp-caption-text\">Figure 1: Download Jersey<\/figcaption><\/figure><\/p>\n<h3><a name=\"createserver\"><\/a>4.2 Create the server project<\/h3>\n<p>Fire up eclipse and choose from the menu <code>File-&gt;New-&gt;Other<\/code>. From the list choose Dynamic Web Project.<\/p>\n<p><figure id=\"attachment_37205\" aria-describedby=\"caption-attachment-37205\" style=\"width: 629px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/02-Create-dynamic-web-project.png\"><img decoding=\"async\" class=\"wp-image-37205 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/02-Create-dynamic-web-project.png\" alt=\"Figure 2: Create dynamic web project\" width=\"629\" height=\"518\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/02-Create-dynamic-web-project.png 629w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/02-Create-dynamic-web-project-300x247.png 300w\" sizes=\"(max-width: 629px) 100vw, 629px\" \/><\/a><figcaption id=\"caption-attachment-37205\" class=\"wp-caption-text\">Figure 2: Create dynamic web project<\/figcaption><\/figure><\/p>\n<h3><a name=\"copylibs\"><\/a>4.3 Copy Jersey Files<\/h3>\n<p>Copy all the Jersey jar files from the downloaded zip into the folder <code>WebContent-&gt;WEB-INF-&gt;lib<\/code>.<\/p>\n<p><figure id=\"attachment_37206\" aria-describedby=\"caption-attachment-37206\" style=\"width: 382px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/03-Copy-jars-into-lib-folder.png\"><img decoding=\"async\" class=\"wp-image-37206 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/03-Copy-jars-into-lib-folder.png\" alt=\"Figure 3: Copy jars into lib folder\" width=\"382\" height=\"450\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/03-Copy-jars-into-lib-folder.png 382w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/03-Copy-jars-into-lib-folder-255x300.png 255w\" sizes=\"(max-width: 382px) 100vw, 382px\" \/><\/a><figcaption id=\"caption-attachment-37206\" class=\"wp-caption-text\">Figure 3: Copy jars into lib folder<\/figcaption><\/figure><\/p>\n<h2><a name=\"codingserver\"><\/a>5. Coding the server<\/h2>\n<p>Create a new pojo java class.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Server class<\/em><\/span><\/p>\n<pre class=\"brush:java\">@Path(\"\/restserver\")\npublic class RestServer {\n\n}\n<\/pre>\n<p>This class use the annotation <code>@Path<\/code> of the specification JAX-RS. It&#8217;s a plain old java object because inherits no one. The JAX-RS specification of Jersey uses annotations to create the REST services.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Text response<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t@GET\n\t@Produces(MediaType.TEXT_PLAIN)\n\tpublic String serverMessageText() {\n\t\treturn \"This is a message from the server\";\n\t}\n<\/pre>\n<p>When you make an html request with a <code>GET<\/code> with plain text as the type of the data, this content is served.<br \/>\nThe annotation <code>@GET<\/code>, serves an html GET request and the annotation <code>@Produces<\/code>, specify the type of data of the response according to the request. The server first analyzes the request and then based on the data type requested it sends the response. Request\/Response is the standard html communication protocol. REST uses the standard request\/response communication protocol.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>XML response<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t@GET\n\t@Produces(MediaType.TEXT_XML)\n\tpublic String serverMessageXML() {\n\t\treturn \"  This is a message from the server \";\n\t}\n<\/pre>\n<p>When you make an html request with a <code>GET<\/code> with XML as the type of the data, this content is served.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>JSON response<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t@GET\n\t@Produces(MediaType.APPLICATION_JSON)\n\tpublic String serverMessageJSON() {\n\t\treturn \"[{'message' : 'server json message', 'content' : 'message content'}]\";\n\t}\n\n<\/pre>\n<p>When you make an html request with a <code>GET<\/code> with JSON as the type of the data, this content is served.<\/p>\n<h2><a name=\"serverwebxml\"><\/a>6. The server web.xml<\/h2>\n<p>In the server we are going to use the web.xml configuration to expose our REST services and define our paths.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>servlet<\/em><\/span><\/p>\n<pre class=\"brush:xml\"> &lt;servlet&gt;\n    &lt;servlet-name&gt;Rest Server&lt;\/servlet-name&gt;\n    &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;\/servlet-class&gt;\n    &lt;init-param&gt;\n        &lt;param-name&gt;jersey.config.server.provider.packages&lt;\/param-name&gt;\n        &lt;param-value&gt;com.example&lt;\/param-value&gt;\n    &lt;\/init-param&gt;\n    &lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;\n  &lt;\/servlet&gt;\n<\/pre>\n<p>This defines the servlet and map the appropriate jersey class to our package. To make the Jersey library recognizes where are the content to be served.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline;\"><em>Servlet mapping<\/em><\/span><\/p>\n<pre class=\"brush:xml\">  &lt;servlet-mapping&gt;\n    &lt;servlet-name&gt;Rest Server&lt;\/servlet-name&gt;\n    &lt;url-pattern&gt;\/server\/*&lt;\/url-pattern&gt;\n  &lt;\/servlet-mapping&gt;  \n<\/pre>\n<p>The servlet mapping, maps the content of our class to the URI used in the browser.<\/p>\n<h2><a name=\"clientproject\"><\/a>7. Create the client project<\/h2>\n<p>In the file menu choose File -&gt; New -&gt; Other<\/p>\n<p><figure id=\"attachment_37208\" aria-describedby=\"caption-attachment-37208\" style=\"width: 646px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/04-New-Project.png\"><img decoding=\"async\" class=\"wp-image-37208 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/04-New-Project.png\" alt=\"Figure 4: New Project\" width=\"646\" height=\"422\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/04-New-Project.png 646w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/04-New-Project-300x196.png 300w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><\/a><figcaption id=\"caption-attachment-37208\" class=\"wp-caption-text\">Figure 4: New Project<\/figcaption><\/figure><\/p>\n<p>Now from the list choose Vaadin 7 project<\/p>\n<p><figure id=\"attachment_37209\" aria-describedby=\"caption-attachment-37209\" style=\"width: 524px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/05-Vaadin-Project.png\"><img decoding=\"async\" class=\"wp-image-37209 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/05-Vaadin-Project.png\" alt=\"Figure 5: Vaadin Project\" width=\"524\" height=\"499\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/05-Vaadin-Project.png 524w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/05-Vaadin-Project-300x286.png 300w\" sizes=\"(max-width: 524px) 100vw, 524px\" \/><\/a><figcaption id=\"caption-attachment-37209\" class=\"wp-caption-text\">Figure 5: Vaadin Project<\/figcaption><\/figure><\/p>\n<p>Press&nbsp;next and name your project then press finish.<\/p>\n<p>Copy all the Jersey jar files from the downloaded zip into the folder <code>WebContent-&gt;WEB-INF-&gt;lib<\/code>. As we did with the server.<\/p>\n<h2><a name=\"codingclient\"><\/a>8. Coding the client project<\/h2>\n<h3><a name=\"clientclass\"><\/a>8.1 Client Class to access the server<\/h3>\n<p>We are going to create a supplementary client class to create the server REST services.<br \/>\nCreate a POJO class:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>POJO client<\/em><\/span><\/p>\n<pre class=\"brush:java\">public class RestClient {\n\t\n}\n<\/pre>\n<p>In this class we are going to create all the client methods we need to access the data on the server.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>fields<\/em><\/span><\/p>\n<pre class=\"brush:java\">\tClientConfig config;\n\tClient client;\n\tWebTarget webtarget;\n<\/pre>\n<p>Create the fields of the the Jersey REST client.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Constructor<\/em><\/span><\/p>\n<pre class=\"brush:java\">\tpublic RestClient(){\n\t\tconfig = new ClientConfig();\n\t\tclient = ClientBuilder.newClient(config);\n\t\twebtarget = client.target(\"http:\/\/localhost:8080\/JaxRestHello\");\n\t}\n<\/pre>\n<p>In the constructor of the Jersey client, we have our base URI to access the REST services.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>getResponse<\/em><\/span><\/p>\n<pre class=\"brush:java\">\tpublic String getResponse(){\n\t\tString response = webtarget.path(\"server\").\n\t\t\t\tpath(\"restserver\").\n\t\t\t\trequest().\n\t\t\t\taccept(MediaType.TEXT_PLAIN).\n\t\t\t\tget(Response.class).toString();\n\t\treturn response;\n\t}\n<\/pre>\n<p>This is a method to get the response from the server. The response could tell us the state of the server and the availability of the services.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Get text answer<\/em><\/span><\/p>\n<pre class=\"brush:java\">\tpublic String getAnswerText(){\n\t\tString answer = \n\t\t        webtarget.path(\"server\").\n\t\t        path(\"restserver\").\n\t\t        request().\n\t\t        accept(MediaType.TEXT_PLAIN).\n\t\t        get(String.class);\n\t\treturn answer;\n\t}\n<\/pre>\n<p>This is a method to get a plain text answer. In the field <code>accept<\/code>, we specify the type of the response. With REST, the data between the client and the server is just plain text but here we could know the kind of structure these plain text has. In this example it could be just plain text, XML or JSON.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Get XML answer<\/em><\/span><\/p>\n<pre class=\"brush:java\">\tpublic String getAnswerXML(){\n\t\tString answer = \n\t\t        webtarget.path(\"server\").\n\t\t        path(\"restserver\").\n\t\t        request().\n\t\t        accept(MediaType.TEXT_XML).\n\t\t        get(String.class);\n\t\treturn answer;\n\t}\n<\/pre>\n<p>This method gets an XML answer from the server, note the fields <code>path<\/code>, these fields are append to the base URI created in the constructor of the class.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Get JSON<\/em><\/span><\/p>\n<pre class=\"brush:java\">\tpublic String getAnswerJSON(){\n\t\tString answer = \n\t\t        webtarget.path(\"server\").\n\t\t        path(\"restserver\").\n\t\t        request().\n\t\t        accept(MediaType.APPLICATION_JSON).\n\t\t        get(String.class);\n\t\treturn answer;\n\t}\n<\/pre>\n<p>JSON is just plain text with some predefined structure.<\/p>\n<h3><a name=\"vaadinui\"><\/a>8.2 Vaadin UI<\/h3>\n<p>In the <code>init<\/code> class of our Vaadin application we create an instance of the client class to access the REST services from our web application. Remember the REST server could be anywhere in the Internet. It could be on the same server as the client but we can have multiples REST servers all around the world and a client accessing all of them.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Main layout<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\tfinal VerticalLayout layout = new VerticalLayout();\n\t\tlayout.setMargin(true);\n\t\tsetContent(layout);\n<\/pre>\n<p>We create the main layout of our application.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Rest client Instance<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\tRestClient restClient = new RestClient();\n<\/pre>\n<p>We create an instance of our REST client, to use it from the Vaadin user interface.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Feedback label<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\tLabel resultLabel = new Label();\n\t\tresultLabel.setWidth(\"100%\");\n\t\tresultLabel.setHeight(\"200px\");\n\t\tresultLabel.addStyleName(\"h1\");\n\t\tresultLabel.addStyleName(\"mylabelstyle\");\n<\/pre>\n<p>We create a label to put the feedback from our server, and make some adjustments and styles to the label just for this example purpose.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Layout for buttons<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\tHorizontalLayout hLayot = new HorizontalLayout();\n<\/pre>\n<p>We are going to create some buttons to get different answers from the server, and we organize it on an horizontal layout.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Get Response<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\tButton buttonGetResponse = new Button(\"Get Response\");\n\t\tbuttonGetResponse.addClickListener(new Button.ClickListener() {\n\t\t\tpublic void buttonClick(ClickEvent event) {\n\t\t\t\tresultLabel.setValue(restClient.getResponse());\n\t\t\t}\n\t\t});\n<\/pre>\n<p>This is a button to get the server response. With this response we can check the status of the server.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Text Answer<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\tButton buttonGetText = new Button(\"Get Text Answer\");\n\t\tbuttonGetText.addClickListener(new Button.ClickListener() {\n\t\t\tpublic void buttonClick(ClickEvent event) {\n\t\t\t\tresultLabel.setValue(restClient.getAnswerText());\n\t\t\t}\n\t\t});\n<\/pre>\n<p>This is a button to get the text answer from the REST server.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>XML Answer<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\tButton buttonGetXml = new Button(\"Get XML Answer\");\n\t\tbuttonGetXml.addClickListener(new Button.ClickListener() {\n\t\t\tpublic void buttonClick(ClickEvent event) {\n\t\t\t\tresultLabel.setValue(restClient.getAnswerXML());\n\t\t\t}\n\t\t});\n<\/pre>\n<p>With this button we get an XML response from the server. We are using the client class created before to call these methods.[ulp id=&#8217;YBvYYzEYBUrADqmI&#8217;]<\/p>\n<p><span style=\"text-decoration: underline;\"><em>JSON Answer<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\tButton buttonGetJson = new Button(\"Get JSON Answer\");\n\t\tbuttonGetJson.addClickListener(new Button.ClickListener() {\n\t\t\tpublic void buttonClick(ClickEvent event) {\n\t\t\t\tresultLabel.setValue(restClient.getAnswerJSON());\n\t\t\t}\n\t\t});\n<\/pre>\n<p>A JSON answer from the server, JSON has been very popular lately and you could transfer it with REST.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Add elements to the layout<\/em><\/span><\/p>\n<pre class=\"brush:java\">\t\thLayot.addComponent(buttonGetResponse);\n\t\thLayot.addComponent(buttonGetText);\n\t\thLayot.addComponent(buttonGetXml);\n\t\thLayot.addComponent(buttonGetJson);\n\t\tlayout.addComponent(resultLabel);\n\t\tlayout.addComponent(hLayot);\n<\/pre>\n<p>Here we add all elements to the layout.<\/p>\n<h2><a name=\"completesource\"><\/a>9. The complete source code<\/h2>\n<h3><a name=\"serversource\"><\/a>9.1 The server source code<\/h3>\n<p><span style=\"text-decoration: underline;\"><em>RestServer.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.example;\n\nimport javax.ws.rs.GET;\nimport javax.ws.rs.Path;\nimport javax.ws.rs.Produces;\nimport javax.ws.rs.core.MediaType;\n\n@Path(\"\/restserver\")\npublic class RestServer {\n\n\t@GET\n\t@Produces(MediaType.TEXT_PLAIN)\n\tpublic String serverMessageText() {\n\t\treturn \"This is a message from the server\";\n\t}\n\n\t@GET\n\t@Produces(MediaType.TEXT_XML)\n\tpublic String serverMessageXML() {\n\t\treturn \"  This is a message from the server \";\n\t}\n\t@GET\n\t@Produces(MediaType.APPLICATION_JSON)\n\tpublic String serverMessageJSON() {\n\t\treturn \"[{'message' : 'server json message', 'content' : 'message content'}]\";\n\t}\n}\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>web.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;web-app xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns=\"http:\/\/xmlns.jcp.org\/xml\/ns\/javaee\" xsi:schemaLocation=\"http:\/\/xmlns.jcp.org\/xml\/ns\/javaee http:\/\/xmlns.jcp.org\/xml\/ns\/javaee\/web-app_3_1.xsd\" id=\"WebApp_ID\" version=\"3.1\"&gt;\n  &lt;display-name&gt;JaxRestHello&lt;\/display-name&gt;\n &lt;servlet&gt;\n    &lt;servlet-name&gt;Rest Server&lt;\/servlet-name&gt;\n    &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;\/servlet-class&gt;\n    &lt;init-param&gt;\n        &lt;param-name&gt;jersey.config.server.provider.packages&lt;\/param-name&gt;\n        &lt;param-value&gt;com.example&lt;\/param-value&gt;\n    &lt;\/init-param&gt;\n    &lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;\n  &lt;\/servlet&gt;\n  &lt;servlet-mapping&gt;\n    &lt;servlet-name&gt;Rest Server&lt;\/servlet-name&gt;\n    &lt;url-pattern&gt;\/server\/*&lt;\/url-pattern&gt;\n  &lt;\/servlet-mapping&gt;  \n&lt;\/web-app&gt;\n<\/pre>\n<h3><a name=\"clientsource\"><\/a>9.2 The client Source Code<\/h3>\n<p><span style=\"text-decoration: underline;\"><em>RestClient.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.example.vaadin_rest_example;\n\nimport javax.ws.rs.client.Client;\nimport javax.ws.rs.client.ClientBuilder;\nimport javax.ws.rs.client.WebTarget;\nimport javax.ws.rs.core.MediaType;\nimport javax.ws.rs.core.Response;\n\nimport org.glassfish.jersey.client.ClientConfig;\n\npublic class RestClient {\n\tClientConfig config;\n\tClient client;\n\tWebTarget webtarget;\n\t\n\tpublic RestClient(){\n\t\tconfig = new ClientConfig();\n\t\tclient = ClientBuilder.newClient(config);\n\t\twebtarget = client.target(\"http:\/\/localhost:8080\/JaxRestHello\");\n\t}\n\t\n\tpublic String getResponse(){\n\t\tString response = webtarget.path(\"server\").\n\t\t\t\tpath(\"restserver\").\n\t\t\t\trequest().\n\t\t\t\taccept(MediaType.TEXT_PLAIN).\n\t\t\t\tget(Response.class).toString();\n\t\treturn response;\n\t}\n\t\n\tpublic String getAnswerText(){\n\t\tString answer = \n\t\t        webtarget.path(\"server\").\n\t\t        path(\"restserver\").\n\t\t        request().\n\t\t        accept(MediaType.TEXT_PLAIN).\n\t\t        get(String.class);\n\t\treturn answer;\n\t}\n\n\tpublic String getAnswerXML(){\n\t\tString answer = \n\t\t        webtarget.path(\"server\").\n\t\t        path(\"restserver\").\n\t\t        request().\n\t\t        accept(MediaType.TEXT_XML).\n\t\t        get(String.class);\n\t\treturn answer;\n\t}\n\n\tpublic String getAnswerJSON(){\n\t\tString answer = \n\t\t        webtarget.path(\"server\").\n\t\t        path(\"restserver\").\n\t\t        request().\n\t\t        accept(MediaType.APPLICATION_JSON).\n\t\t        get(String.class);\n\t\treturn answer;\n\t}\n\t\n}\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>Vaadin_rest_exampleUI.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.example.vaadin_rest_example;\n\nimport javax.servlet.annotation.WebServlet;\n\nimport com.vaadin.annotations.Theme;\nimport com.vaadin.annotations.VaadinServletConfiguration;\nimport com.vaadin.server.VaadinRequest;\nimport com.vaadin.server.VaadinServlet;\nimport com.vaadin.ui.Button;\nimport com.vaadin.ui.Button.ClickEvent;\nimport com.vaadin.ui.HorizontalLayout;\nimport com.vaadin.ui.Label;\nimport com.vaadin.ui.UI;\nimport com.vaadin.ui.VerticalLayout;\n\n@SuppressWarnings(\"serial\")\n@Theme(\"vaadin_rest_example\")\npublic class Vaadin_rest_exampleUI extends UI {\n\n\t@WebServlet(value = \"\/*\", asyncSupported = true)\n\t@VaadinServletConfiguration(productionMode = false, ui = Vaadin_rest_exampleUI.class, widgetset = \"com.example.vaadin_rest_example.widgetset.Vaadin_rest_exampleWidgetset\")\n\tpublic static class Servlet extends VaadinServlet {\n\t}\n\n\t@Override\n\tprotected void init(VaadinRequest request) {\n\t\tfinal VerticalLayout layout = new VerticalLayout();\n\t\tlayout.setMargin(true);\n\t\tsetContent(layout);\n\n\t\tRestClient restClient = new RestClient();\n\t\t\n\t\tLabel resultLabel = new Label();\n\t\tresultLabel.setWidth(\"100%\");\n\t\tresultLabel.setHeight(\"200px\");\n\t\tresultLabel.addStyleName(\"h1\");\n\t\tresultLabel.addStyleName(\"mylabelstyle\");\n\t\tHorizontalLayout hLayot = new HorizontalLayout();\n\t\t\n\t\tButton buttonGetResponse = new Button(\"Get Response\");\n\t\tbuttonGetResponse.addClickListener(new Button.ClickListener() {\n\t\t\tpublic void buttonClick(ClickEvent event) {\n\t\t\t\tresultLabel.setValue(restClient.getResponse());\n\t\t\t}\n\t\t});\n\t\t\n\t\tButton buttonGetText = new Button(\"Get Text Answer\");\n\t\tbuttonGetText.addClickListener(new Button.ClickListener() {\n\t\t\tpublic void buttonClick(ClickEvent event) {\n\t\t\t\tresultLabel.setValue(restClient.getAnswerText());\n\t\t\t}\n\t\t});\n\n\t\tButton buttonGetXml = new Button(\"Get XML Answer\");\n\t\tbuttonGetXml.addClickListener(new Button.ClickListener() {\n\t\t\tpublic void buttonClick(ClickEvent event) {\n\t\t\t\tresultLabel.setValue(restClient.getAnswerXML());\n\t\t\t}\n\t\t});\n\n\t\tButton buttonGetJson = new Button(\"Get JSON Answer\");\n\t\tbuttonGetJson.addClickListener(new Button.ClickListener() {\n\t\t\tpublic void buttonClick(ClickEvent event) {\n\t\t\t\tresultLabel.setValue(restClient.getAnswerJSON());\n\t\t\t}\n\t\t});\n\t\t\n\t\thLayot.addComponent(buttonGetResponse);\n\t\thLayot.addComponent(buttonGetText);\n\t\thLayot.addComponent(buttonGetXml);\n\t\thLayot.addComponent(buttonGetJson);\n\t\tlayout.addComponent(resultLabel);\n\t\tlayout.addComponent(hLayot);\n\t}\n\n}\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>vaadin_rest_example.scss<\/em><\/span><\/p>\n<pre class=\"brush:java\">@import \"..\/valo\/valo.scss\";\n\n@mixin vaadin_rest_example {\n  @include valo;\n\n\t.v-label-mylabelstyle {\n\t    color: white;\n\t    text-align: center;\n\t    background-color: black;\t\n\t    border-color: white;\n\t    font-weight: bold;\n\t}\n}\n<\/pre>\n<h2><a name=\"runningexample\"><\/a>10. Running the example<\/h2>\n<p>First right click on the server project folder and choose Run as -&gt; Run on server choose Tomcat 8 server and press finish.<br \/>\nWhen the server is running right click on the Vaadin project folder and choose Run as -&gt; Run on server choose Tomcat 8 server and press finish.<\/p>\n<h2><a name=\"results\"><\/a>11. Results<\/h2>\n<h3><a name=\"getresponse\"><\/a>11.1 Get the response<\/h3>\n<p><figure id=\"attachment_37210\" aria-describedby=\"caption-attachment-37210\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/06-Get-Response.png\"><img decoding=\"async\" class=\"wp-image-37210 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/06-Get-Response.png\" alt=\"Figure 6: Get Response\" width=\"635\" height=\"379\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/06-Get-Response.png 635w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/06-Get-Response-300x179.png 300w\" sizes=\"(max-width: 635px) 100vw, 635px\" \/><\/a><figcaption id=\"caption-attachment-37210\" class=\"wp-caption-text\">Figure 6: Get Response<\/figcaption><\/figure><\/p>\n<p>Get the status of the server<\/p>\n<h3><a name=\"gettext\"><\/a>11.2 Get the plain text<\/h3>\n<p><figure id=\"attachment_37211\" aria-describedby=\"caption-attachment-37211\" style=\"width: 622px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/07-Get-Text.png\"><img decoding=\"async\" class=\"wp-image-37211 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/07-Get-Text.png\" alt=\"Figure 7: Get Text\" width=\"622\" height=\"373\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/07-Get-Text.png 622w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/07-Get-Text-300x180.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><figcaption id=\"caption-attachment-37211\" class=\"wp-caption-text\">Figure 7: Get Text<\/figcaption><\/figure><\/p>\n<p>Get the plain text answer from the server<\/p>\n<h3><a name=\"getxml\"><\/a>11.3 Get the XML<\/h3>\n<p><figure id=\"attachment_37214\" aria-describedby=\"caption-attachment-37214\" style=\"width: 623px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/08-Get-XML.png\"><img decoding=\"async\" class=\"wp-image-37214 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/08-Get-XML.png\" alt=\"Figure 8: Get XML\" width=\"623\" height=\"377\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/08-Get-XML.png 623w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/08-Get-XML-300x182.png 300w\" sizes=\"(max-width: 623px) 100vw, 623px\" \/><\/a><figcaption id=\"caption-attachment-37214\" class=\"wp-caption-text\">Figure 8: Get XML<\/figcaption><\/figure><\/p>\n<p>Get the XML answer from the server<\/p>\n<h3><a name=\"getjson\"><\/a>11.4 Get the JSON<\/h3>\n<p><figure id=\"attachment_37215\" aria-describedby=\"caption-attachment-37215\" style=\"width: 625px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/09-Get-JSON.png\"><img decoding=\"async\" class=\"wp-image-37215 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/09-Get-JSON.png\" alt=\"Figure 9: Get JSON\" width=\"625\" height=\"375\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/09-Get-JSON.png 625w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/09-Get-JSON-300x180.png 300w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/a><figcaption id=\"caption-attachment-37215\" class=\"wp-caption-text\">Figure 9: Get JSON<\/figcaption><\/figure><\/p>\n<p>Get the JSON answer from the server<\/p>\n<h2><a name=\"downloadsource\"><\/a>12. Download the Source Code<\/h2>\n<p>This was an example of: Vaadin REST.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the Eclipse project here:&nbsp;<strong><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/VaadinRestExample.zip\">VaadinRestExample<\/a><br \/>\n<\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>REST stands for Representational State Transfer. Created by Roy Fielding in the year 2000, is a communication protocol where everything is a resource. REST principal characteristics are: client-server, stateless, cache-able, layered and uniform interface to access resources. Resources are accessed using a stateless protocol like HTTP. REST allows text, XML, JSON and other resources. PUT, &hellip;<\/p>\n","protected":false},"author":77,"featured_media":33079,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1358],"tags":[],"class_list":["post-37202","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vaadin"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Vaadin Rest Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"REST stands for Representational State Transfer. Created by Roy Fielding in the year 2000, is a communication protocol where everything is a resource.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Vaadin Rest Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"REST stands for Representational State Transfer. Created by Roy Fielding in the year 2000, is a communication protocol where everything is a resource.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-17T12:00:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-09T10:11:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jesus Boadas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@jboadas\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jesus Boadas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/\"},\"author\":{\"name\":\"Jesus Boadas\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/506f9c2b38156c7f94bba77757206dd7\"},\"headline\":\"Vaadin Rest Example\",\"datePublished\":\"2016-05-17T12:00:32+00:00\",\"dateModified\":\"2019-04-09T10:11:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/\"},\"wordCount\":1284,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\",\"articleSection\":[\"Vaadin\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/\",\"name\":\"Vaadin Rest Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\",\"datePublished\":\"2016-05-17T12:00:32+00:00\",\"dateModified\":\"2019-04-09T10:11:23+00:00\",\"description\":\"REST stands for Representational State Transfer. Created by Roy Fielding in the year 2000, is a communication protocol where everything is a resource.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Vaadin\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/vaadin\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Vaadin Rest Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/506f9c2b38156c7f94bba77757206dd7\",\"name\":\"Jesus Boadas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/Jesus-Boadas_avatar_1476120926-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/Jesus-Boadas_avatar_1476120926-96x96.jpg\",\"caption\":\"Jesus Boadas\"},\"description\":\"I'm a self taught programmer, I began programming back in 1991 using an IBM A10 mainframe with Pascal an Assembler IBM 360\/70 emulator and Turbo C on a X86 PC, since that I work for the banking industry with emerging technologies like Fox Pro, Visual Fox Pro, Visual Basic, Visual C++, Borland C++, lately I moved out to the Airline industry, leading designing and programming in-house web applications with Flex, Actionscript, PHP, Python and Rails and in the last 7 years I focused all my work in Java, working on Linux servers using GlassFish, TomCat, Apache and MySql.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\",\"https:\/\/ve.linkedin.com\/in\/jesus-boadas\",\"https:\/\/x.com\/jboadas\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/jesus-boadas\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Vaadin Rest Example - Java Code Geeks","description":"REST stands for Representational State Transfer. Created by Roy Fielding in the year 2000, is a communication protocol where everything is a resource.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/","og_locale":"en_US","og_type":"article","og_title":"Vaadin Rest Example - Java Code Geeks","og_description":"REST stands for Representational State Transfer. Created by Roy Fielding in the year 2000, is a communication protocol where everything is a resource.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2016-05-17T12:00:32+00:00","article_modified_time":"2019-04-09T10:11:23+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","type":"image\/jpeg"}],"author":"Jesus Boadas","twitter_card":"summary_large_image","twitter_creator":"@jboadas","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Jesus Boadas","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/"},"author":{"name":"Jesus Boadas","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/506f9c2b38156c7f94bba77757206dd7"},"headline":"Vaadin Rest Example","datePublished":"2016-05-17T12:00:32+00:00","dateModified":"2019-04-09T10:11:23+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/"},"wordCount":1284,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","articleSection":["Vaadin"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/","name":"Vaadin Rest Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","datePublished":"2016-05-17T12:00:32+00:00","dateModified":"2019-04-09T10:11:23+00:00","description":"REST stands for Representational State Transfer. Created by Roy Fielding in the year 2000, is a communication protocol where everything is a resource.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-rest-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"Vaadin","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/vaadin\/"},{"@type":"ListItem","position":5,"name":"Vaadin Rest Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/506f9c2b38156c7f94bba77757206dd7","name":"Jesus Boadas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/Jesus-Boadas_avatar_1476120926-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/Jesus-Boadas_avatar_1476120926-96x96.jpg","caption":"Jesus Boadas"},"description":"I'm a self taught programmer, I began programming back in 1991 using an IBM A10 mainframe with Pascal an Assembler IBM 360\/70 emulator and Turbo C on a X86 PC, since that I work for the banking industry with emerging technologies like Fox Pro, Visual Fox Pro, Visual Basic, Visual C++, Borland C++, lately I moved out to the Airline industry, leading designing and programming in-house web applications with Flex, Actionscript, PHP, Python and Rails and in the last 7 years I focused all my work in Java, working on Linux servers using GlassFish, TomCat, Apache and MySql.","sameAs":["http:\/\/www.javacodegeeks.com\/","https:\/\/ve.linkedin.com\/in\/jesus-boadas","https:\/\/x.com\/jboadas"],"url":"https:\/\/examples.javacodegeeks.com\/author\/jesus-boadas\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/37202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=37202"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/37202\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/33079"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=37202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=37202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=37202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}