{"id":18876,"date":"2013-11-13T10:00:51","date_gmt":"2013-11-13T08:00:51","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=18876"},"modified":"2014-09-21T11:54:25","modified_gmt":"2014-09-21T08:54:25","slug":"restful-web-services-with-java","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html","title":{"rendered":"RESTful Web Services with Java"},"content":{"rendered":"<p>REST stands for REpresentational State Transfer, was first introduced by Roy Fielding in his thesis <a href=\"http:\/\/www.ics.uci.edu\/~fielding\/pubs\/dissertation\/rest_arch_style.htm\">&#8220;Architectural Styles and the Design of Network-based Software Architectures&#8221;<\/a> in year 2000.<\/p>\n<p>REST is an architectural style. HTTP is a protocol which contains the set of REST architectural constraints.<\/p>\n<h2>REST fundamentals <\/h2>\n<p>&nbsp;<br \/>\n&nbsp;<\/p>\n<ul>\n<li>Everything in REST is considered as a resource.<\/li>\n<li>Every resource is identified by an URI.<\/li>\n<li>Uses uniform interfaces. Resources are handled using POST, GET, PUT, DELETE operations which are similar to Create, Read, update and Delete(CRUD) operations.<\/li>\n<li>Be stateless. Every request is an independent request. Each request from client to server must contain all the information necessary to understand the request.<\/li>\n<li>Communications are done via representations. E.g. XML, JSON<\/li>\n<\/ul>\n<h2>RESTful Web Services<\/h2>\n<p>RESTful Web Services have embraced by large service providers across the web as an alternative to SOAP based Web Services due to its simplicity. This post will demonstrate how to create a RESTful Web Service and client using Jersey framework which extends JAX-RS API. Examples are done using Eclipse IDE and Java SE 6.<\/p>\n<h2><span style=\"text-decoration: underline;\">Creating RESTful Web Service<\/span><\/h2>\n<ul>\n<ul>\n<li>In Eclipse, create a new dynamic web project called &#8220;RESTfulWS&#8221;<\/li>\n<\/ul>\n<\/ul>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-07-17-06-05.png\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-18892\" alt=\"Screenshot from 2013-11-07 17-06-05\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-07-17-06-05-258x300.png\" width=\"258\" height=\"300\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-07-17-06-05-258x300.png 258w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-07-17-06-05.png 622w\" sizes=\"(max-width: 258px) 100vw, 258px\" \/><\/a><\/p>\n<ul>\n<ul>\n<li>Download Jersey zip bundle from <a href=\"https:\/\/jersey.java.net\/download.html\">here<\/a>. Jersey version used in these examples is 1.17.1. Once you unzip it you&#8217;ll have a directory called &#8220;jersey-archive-1.17.1&#8221;. Inside it find the lib directory. Copy following jars from there and paste them inside WEB-INF -&gt; lib folder in your project. Once you&#8217;ve done that, add those jars to your project build path as well.\n<ol>\n<li>asm-3.1.jar<\/li>\n<li>jersey-client-1.17.1.jar<\/li>\n<li>jersey-core-1.17.1.jar<\/li>\n<li>jersey-server-1.17.1.jar<\/li>\n<li>jersey-servlet-1.17.1.jar<\/li>\n<li>jsr311-api-1.1.1.jar<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/ul>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-02-54-15.png\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-18893\" alt=\"Screenshot from 2013-11-08 02-54-15\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-02-54-15-250x300.png\" width=\"250\" height=\"300\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-02-54-15-250x300.png 250w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-02-54-15.png 393w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-07-17-17-36.png\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-18894\" alt=\"Screenshot from 2013-11-07 17-17-36\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-07-17-17-36-300x281.png\" width=\"300\" height=\"281\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-07-17-17-36-300x281.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-07-17-17-36.png 774w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<ul>\n<li>In your project, inside Java Resources -&gt; src create a new package called &#8220;com.eviac.blog.restws&#8221;. Inside it create a new java class called &#8220;UserInfo&#8221;. Also include the given web.xml file inside WEB-INF folder.<\/li>\n<\/ul>\n<\/ul>\n<h4>UserInfo.java<\/h4>\n<pre class=\" brush:java\">package com.eviac.blog.restws;\r\n\r\nimport javax.ws.rs.GET;\r\nimport javax.ws.rs.Path;\r\nimport javax.ws.rs.PathParam;\r\nimport javax.ws.rs.Produces;\r\nimport javax.ws.rs.core.MediaType;\r\n\r\n\/**\r\n * \r\n * @author pavithra\r\n * \r\n *\/\r\n\r\n\/\/ @Path here defines class level path. Identifies the URI path that \r\n\/\/ a resource class will serve requests for.\r\n@Path(\"UserInfoService\")\r\npublic class UserInfo {\r\n\r\n \/\/ @GET here defines, this method will method will process HTTP GET\r\n \/\/ requests.\r\n @GET\r\n \/\/ @Path here defines method level path. Identifies the URI path that a\r\n \/\/ resource class method will serve requests for.\r\n @Path(\"\/name\/{i}\")\r\n \/\/ @Produces here defines the media type(s) that the methods\r\n \/\/ of a resource class can produce.\r\n @Produces(MediaType.TEXT_XML)\r\n \/\/ @PathParam injects the value of URI parameter that defined in @Path\r\n \/\/ expression, into the method.\r\n public String userName(@PathParam(\"i\") String i) {\r\n\r\n  String name = i;\r\n  return \"&lt;User&gt;\" + \"&lt;Name&gt;\" + name + \"&lt;\/Name&gt;\" + \"&lt;\/User&gt;\";\r\n }\r\n\r\n @GET \r\n @Path(\"\/age\/{j}\") \r\n @Produces(MediaType.TEXT_XML)\r\n public String userAge(@PathParam(\"j\") int j) {\r\n\r\n  int age = j;\r\n  return \"&lt;User&gt;\" + \"&lt;Age&gt;\" + age + \"&lt;\/Age&gt;\" + \"&lt;\/User&gt;\";\r\n }\r\n}<\/pre>\n<h4>web.xml<\/h4>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;  \r\n&lt;web-app xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns=\"http:\/\/java.sun.com\/xml\/ns\/javaee\" xmlns:web=\"http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd\" xsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd\" id=\"WebApp_ID\" version=\"2.5\"&gt;  \r\n  &lt;display-name&gt;RESTfulWS&lt;\/display-name&gt;  \r\n  &lt;servlet&gt;  \r\n    &lt;servlet-name&gt;Jersey REST Service&lt;\/servlet-name&gt;  \r\n    &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;\/servlet-class&gt;  \r\n    &lt;init-param&gt;  \r\n      &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;\/param-name&gt;  \r\n      &lt;param-value&gt;com.eviac.blog.restws&lt;\/param-value&gt;  \r\n    &lt;\/init-param&gt;  \r\n    &lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;  \r\n  &lt;\/servlet&gt;  \r\n  &lt;servlet-mapping&gt;  \r\n    &lt;servlet-name&gt;Jersey REST Service&lt;\/servlet-name&gt;  \r\n    &lt;url-pattern&gt;\/rest\/*&lt;\/url-pattern&gt;  \r\n  &lt;\/servlet-mapping&gt;  \r\n&lt;\/web-app&gt;<\/pre>\n<ul>\n<ul>\n<li>To run the project, right click on it and click on run as -&gt;run on server.<\/li>\n<li>Execute the following URL in your browser and you&#8217;ll see the output.\n<pre class=\" brush:java\">http:\/\/localhost:8080\/RESTfulWS\/rest\/UserInfoService\/name\/Pavithra<\/pre>\n<\/li>\n<\/ul>\n<\/ul>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-02-04-07.png\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-18895\" alt=\"Screenshot from 2013-11-08 02-04-07\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-02-04-07-300x138.png\" width=\"300\" height=\"138\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-02-04-07-300x138.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-02-04-07.png 810w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h4>output<\/h4>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-03-09-57.png\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-18896\" alt=\"Screenshot from 2013-11-08 03-09-57\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-03-09-57-300x72.png\" width=\"300\" height=\"72\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-03-09-57-300x72.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Screenshot-from-2013-11-08-03-09-57.png 734w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h2><span style=\"text-decoration: underline;\">Creating Client<\/span><\/h2>\n<ul>\n<ul>\n<li>Create a package called &#8220;com.eviac.blog.restclient&#8221;. Inside it create a java class called &#8220;UserInfoClient&#8221;.<\/li>\n<\/ul>\n<\/ul>\n<h4>UserInfoClient.java<\/h4>\n<pre class=\" brush:java\">package com.eviac.blog.restclient;\r\n\r\nimport javax.ws.rs.core.MediaType;\r\n\r\nimport com.sun.jersey.api.client.Client;\r\nimport com.sun.jersey.api.client.ClientResponse;\r\nimport com.sun.jersey.api.client.WebResource;\r\nimport com.sun.jersey.api.client.config.ClientConfig;\r\nimport com.sun.jersey.api.client.config.DefaultClientConfig;\r\n\r\n\/**\r\n * \r\n * @author pavithra\r\n * \r\n *\/\r\npublic class UserInfoClient {\r\n\r\n public static final String BASE_URI = \"http:\/\/localhost:8080\/RESTfulWS\";\r\n public static final String PATH_NAME = \"\/UserInfoService\/name\/\";\r\n public static final String PATH_AGE = \"\/UserInfoService\/age\/\";\r\n\r\n public static void main(String[] args) {\r\n\r\n  String name = \"Pavithra\";\r\n  int age = 25;\r\n\r\n  ClientConfig config = new DefaultClientConfig();\r\n  Client client = Client.create(config);\r\n  WebResource resource = client.resource(BASE_URI);\r\n\r\n  WebResource nameResource = resource.path(\"rest\").path(PATH_NAME + name);\r\n  System.out.println(\"Client Response \\n\"\r\n    + getClientResponse(nameResource));\r\n  System.out.println(\"Response \\n\" + getResponse(nameResource) + \"\\n\\n\");\r\n\r\n  WebResource ageResource = resource.path(\"rest\").path(PATH_AGE + age);\r\n  System.out.println(\"Client Response \\n\"\r\n    + getClientResponse(ageResource));\r\n  System.out.println(\"Response \\n\" + getResponse(ageResource));\r\n }\r\n\r\n \/**\r\n  * Returns client response.\r\n  * e.g : \r\n  * GET http:\/\/localhost:8080\/RESTfulWS\/rest\/UserInfoService\/name\/Pavithra \r\n  * returned a response status of 200 OK\r\n  *\r\n  * @param service\r\n  * @return\r\n  *\/\r\n private static String getClientResponse(WebResource resource) {\r\n  return resource.accept(MediaType.TEXT_XML).get(ClientResponse.class)\r\n    .toString();\r\n }\r\n\r\n \/**\r\n  * Returns the response as XML\r\n  * e.g : &lt;User&gt;&lt;Name&gt;Pavithra&lt;\/Name&gt;&lt;\/User&gt; \r\n  * \r\n  * @param service\r\n  * @return\r\n  *\/\r\n private static String getResponse(WebResource resource) {\r\n  return resource.accept(MediaType.TEXT_XML).get(String.class);\r\n }\r\n}<\/pre>\n<ul>\n<ul>\n<li>Once you run the client program, you&#8217;ll get following output.<\/li>\n<\/ul>\n<\/ul>\n<pre class=\" brush:java\">Client Response \r\nGET http:\/\/localhost:8080\/RESTfulWS\/rest\/UserInfoService\/name\/Pavithra returned a response status of 200 OK\r\nResponse \r\n&lt;User&gt;&lt;Name&gt;Pavithra&lt;\/Name&gt;&lt;\/User&gt;\r\n\r\nClient Response \r\nGET http:\/\/localhost:8080\/RESTfulWS\/rest\/UserInfoService\/age\/25 returned a response status of 200 OK\r\nResponse \r\n&lt;User&gt;&lt;Age&gt;25&lt;\/Age&gt;&lt;\/User&gt;<\/pre>\n<p>Enjoy!<br \/>\n&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/blog.eviac.net\/2013\/11\/restful-web-services-with-java.html\">RESTful Web Services with Java <\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Pavithra Siriwardena at the <a href=\"http:\/\/blog.eviac.net\/\">EVIAC<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>REST stands for REpresentational State Transfer, was first introduced by Roy Fielding in his thesis &#8220;Architectural Styles and the Design of Network-based Software Architectures&#8221; in year 2000. REST is an architectural style. HTTP is a protocol which contains the set of REST architectural constraints. REST fundamentals &nbsp; &nbsp; Everything in REST is considered as a &hellip;<\/p>\n","protected":false},"author":170,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[54],"class_list":["post-18876","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-restful-web-services"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>RESTful Web Services with Java<\/title>\n<meta name=\"description\" content=\"REST stands for REpresentational State Transfer, was first introduced by Roy Fielding in his thesis &quot;Architectural Styles and the Design of Network-based\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RESTful Web Services with Java\" \/>\n<meta property=\"og:description\" content=\"REST stands for REpresentational State Transfer, was first introduced by Roy Fielding in his thesis &quot;Architectural Styles and the Design of Network-based\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-11-13T08:00:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-09-21T08:54:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-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=\"Pavithra Siriwardena\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pavithra Siriwardena\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html\"},\"author\":{\"name\":\"Pavithra Siriwardena\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/786e7973ceced64f8bf483ec0bfa4de4\"},\"headline\":\"RESTful Web Services with Java\",\"datePublished\":\"2013-11-13T08:00:51+00:00\",\"dateModified\":\"2014-09-21T08:54:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html\"},\"wordCount\":390,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"RESTful Web Services\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html\",\"name\":\"RESTful Web Services with Java\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2013-11-13T08:00:51+00:00\",\"dateModified\":\"2014-09-21T08:54:25+00:00\",\"description\":\"REST stands for REpresentational State Transfer, was first introduced by Roy Fielding in his thesis \\\"Architectural Styles and the Design of Network-based\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/11\\\/restful-web-services-with-java.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"RESTful Web Services with Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/786e7973ceced64f8bf483ec0bfa4de4\",\"name\":\"Pavithra Siriwardena\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1774c418cd9aeb9a68960676854bba91e435eaba319a4b3eec6408a015067443?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1774c418cd9aeb9a68960676854bba91e435eaba319a4b3eec6408a015067443?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1774c418cd9aeb9a68960676854bba91e435eaba319a4b3eec6408a015067443?s=96&d=mm&r=g\",\"caption\":\"Pavithra Siriwardena\"},\"sameAs\":[\"http:\\\/\\\/blog.eviac.net\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Pavithra-Siriwardena\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"RESTful Web Services with Java","description":"REST stands for REpresentational State Transfer, was first introduced by Roy Fielding in his thesis \"Architectural Styles and the Design of Network-based","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:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html","og_locale":"en_US","og_type":"article","og_title":"RESTful Web Services with Java","og_description":"REST stands for REpresentational State Transfer, was first introduced by Roy Fielding in his thesis \"Architectural Styles and the Design of Network-based","og_url":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-11-13T08:00:51+00:00","article_modified_time":"2014-09-21T08:54:25+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Pavithra Siriwardena","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Pavithra Siriwardena","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html"},"author":{"name":"Pavithra Siriwardena","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/786e7973ceced64f8bf483ec0bfa4de4"},"headline":"RESTful Web Services with Java","datePublished":"2013-11-13T08:00:51+00:00","dateModified":"2014-09-21T08:54:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html"},"wordCount":390,"commentCount":6,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["RESTful Web Services"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html","url":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html","name":"RESTful Web Services with Java","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2013-11-13T08:00:51+00:00","dateModified":"2014-09-21T08:54:25+00:00","description":"REST stands for REpresentational State Transfer, was first introduced by Roy Fielding in his thesis \"Architectural Styles and the Design of Network-based","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/11\/restful-web-services-with-java.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"RESTful Web Services with Java"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/786e7973ceced64f8bf483ec0bfa4de4","name":"Pavithra Siriwardena","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1774c418cd9aeb9a68960676854bba91e435eaba319a4b3eec6408a015067443?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1774c418cd9aeb9a68960676854bba91e435eaba319a4b3eec6408a015067443?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1774c418cd9aeb9a68960676854bba91e435eaba319a4b3eec6408a015067443?s=96&d=mm&r=g","caption":"Pavithra Siriwardena"},"sameAs":["http:\/\/blog.eviac.net\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Pavithra-Siriwardena"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/18876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/170"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=18876"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/18876\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=18876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=18876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=18876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}