RESTful services with jQuery and Java using JAX-RS and Jersey

NOTE: This is the Java version of this article and its companion app. A PHP version is available here.

This is a more in depth version of my previous post on the same topic. The previous article only covered the HTTP GET method for building RESTful services. This article (and its new companion app) provides an example of building a complete RESTful API using the different HTTP methods:

  • GET to retrieve and search data
  • POST to add data
  • PUT to update data
  • DELETE to delete data

The application used as an example for this article is a Wine Cellar app. You can search for wines, add a wine to your cellar, update and delete wines.


You can run the application here. The create/update/delete features are disabled in this online version. Use the link at the bottom of this post to download a fully enabled version.

The REST API consists of the following methods:

Method URL Action
GET /api/wines Retrieve all wines
GET /api/wines/search/Chateau Search for wines with ‘Chateau’ in their name
GET /api/wines/10 Retrieve wine with id == 10
POST /api/wines Add a new wine
PUT /api/wines/10 Update wine with id == 10
DELETE /api/wines/10 Delete wine with id == 10

 

Implementing the API using JAX-RS

JAX-RS makes it easy to implement this API in Java. You simply create a class defined as follows:

package org.coenraets.cellar;

@Path("/wines")
public class WineResource {

	WineDAO dao = new WineDAO();

	@GET
	@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
	public List<Wine> findAll() {
		return dao.findAll();
	}

	@GET @Path("search/{query}")
	@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
	public List<Wine> findByName(@PathParam("query") String query) {
		return dao.findByName(query);
	}

	@GET @Path("{id}")
	@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
	public Wine findById(@PathParam("id") String id) {
		return dao.findById(Integer.parseInt(id));
	}

	@POST
	@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
	public Wine create(Wine wine) {
		return dao.create(wine);
	}

	@PUT @Path("{id}")
	@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
	public Wine update(Wine wine) {
		return dao.update(wine);
	}

	@DELETE @Path("{id}")
	@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
	public void remove(@PathParam("id") int id) {
		dao.remove(id);
	}
}

Quick look at the JAX-RS annotations used in this class:

  • @GET, @POST, @PUT, @DELETE: HTTP method the class method responds to.
  • @Path: path the method responds to.
  • @Consumes: type of data the method can take as input. The data will automatically be deserialized into a method input parameter. For example, you can pass a wine object to the addWined() method either as JSON or XML. The JSON or XML representation of a new wine is automatically deserialized into the Wine object passed as an argument to the method.
  • @Produces: One or more response content type(s) the method can generate. The method’s return value will be automatically serialized using the content type requested by the client. If the client didn’t request a specific content type, the first content type listed in the @Produces annotation will be used. For example, if you access http://coenraets.org/rest/wines, you get a list of wines represented as JSON because it is the first content type listed in the @Produces annotation of the findAll() method.

The jQuery client below sends data to the server using JSON (addWine() and updateWine() methods).

The approach you use to actually retrieve the data is totally up to you. In this example, I use a simple DAO, but you can of course use your own data access solution.

Testing the API using cURL

If you want to test your API before using it in a client application, you can invoke your REST services straight from a browser address bar. For example, you could try:

You will only be able to test your GET services that way, and even then, it doesn’t give you full control to test all the content types your API can return.

A more versatile solution to test RESTful services is to use cURL, a command line utility for transferring data with URL syntax.

For example, using cURL, you can test the Wine Cellar API with the following commands:

  • Get all wines returned as default content type:
    curl -i -X GET http://localhost:8080/cellar/rest/wines
    
  • Get all wines returned as xml:
    curl -i -X GET http://localhost:8080/cellar/rest/wines -H 'Accept:application/xml'
    
  • Get all wines with ‘chateau’ in their name:
    curl -i -X GET http://localhost:8080/cellar/rest/wines/search/chateau
    
  • Get wine #5:
    curl -i -X GET http://localhost:8080/cellar/rest/wines/5
    
  • Delete wine #5:
    curl -i -X DELETE http://localhost:8080/cellar/rest/wines/5
    
  • Add a new wine:
    curl -i -X POST -H 'Content-Type: application/json' -d '{"name": "New Wine", "year": "2009"}' http://localhost:8080/cellar/rest/wines
    
  • Modify wine #27:
    curl -i -X PUT -H 'Content-Type: application/json' -d '{"id": "27", "name": "New Wine", "year": "2010"}' http://localhost:8080/cellar/rest/wines/27
    

The jQuery Client

Accessing your API through cURL is cool, but there is nothing like a real application to put your API to the test. So the source code (available for download at the end of this post) includes a simple jQuery client to manage your wine cellar.

Here is the jQuery code involved in calling the services:

function findAll() {
	$.ajax({
		type: 'GET',
		url: rootURL,
		dataType: "json", // data type of response
		success: renderList
	});
}

function findByName(searchKey) {
	$.ajax({
		type: 'GET',
		url: rootURL + '/search/' + searchKey,
		dataType: "json",
		success: renderList
	});
}

function findById(id) {
	$.ajax({
		type: 'GET',
		url: rootURL + '/' + id,
		dataType: "json",
		success: function(data){
			$('#btnDelete').show();
			renderDetails(data);
		}
	});
}

function addWine() {
	console.log('addWine');
	$.ajax({
		type: 'POST',
		contentType: 'application/json',
		url: rootURL,
		dataType: "json",
		data: formToJSON(),
		success: function(data, textStatus, jqXHR){
			alert('Wine created successfully');
			$('#btnDelete').show();
			$('#wineId').val(data.id);
		},
		error: function(jqXHR, textStatus, errorThrown){
			alert('addWine error: ' + textStatus);
		}
	});
}

function updateWine() {
	$.ajax({
		type: 'PUT',
		contentType: 'application/json',
		url: rootURL + '/' + $('#wineId').val(),
		dataType: "json",
		data: formToJSON(),
		success: function(data, textStatus, jqXHR){
			alert('Wine updated successfully');
		},
		error: function(jqXHR, textStatus, errorThrown){
			alert('updateWine error: ' + textStatus);
		}
	});
}

function deleteWine() {
	console.log('deleteWine');
	$.ajax({
		type: 'DELETE',
		url: rootURL + '/' + $('#wineId').val(),
		success: function(data, textStatus, jqXHR){
			alert('Wine deleted successfully');
		},
		error: function(jqXHR, textStatus, errorThrown){
			alert('deleteWine error');
		}
	});
}

// Helper function to serialize all the form fields into a JSON string
function formToJSON() {
	return JSON.stringify({
		"id": $('#id').val(),
		"name": $('#name').val(),
		"grapes": $('#grapes').val(),
		"country": $('#country').val(),
		"region": $('#region').val(),
		"year": $('#year').val(),
		"description": $('#description').val()
		});
}

 

Download the Source Code

The source code for this application is hosted on GitHub here. And here is a quick link to the project download (Eclipse Dynamic Web Project). It includes both the Java and jQuery code for the application.

UPDATE (1/11/2012): A version of this application using Backbone.js at the client-side is also available on GitHub here. You can find more information on the Backbone.js of this application here.

I’m interested in your feedback. Let me know what you think and what your experience has been building RESTful-based applications using Java and jQuery.

  • Pingback: RESTful services with jQuery and Java using JAX-RS and Jersey - hostinghanger.in | hostinghanger.in()

  • Pingback: Backbone.js Wine Cellar Tutorial — Part 2: CRUD()

  • Pingback: Backbone.js Wine Cellar Tutorial — Part 1: Getting Started()

  • Gerd

    The best Jersey Rest + JQuery example i´ve seen so far… still searching for an easy solution to solve the “cross-site” – problem… some of yours have any idea what to change on server-side in case of running the JQuery – Client on a different webserver? (eg. webservice is running on http://10.10.10.1:8080/cellar, JQuery – client is running on http://10.10.20.1:8080/index.html)

    • Kenny

      Hi Gerd
      I’ve been running into the cross-site problem aswel and after a lot of research found a few solutions:

      – JSON-P can be used for GET requests ONLY. Also note that it is not very secure.
      – CORS is probably the best way other then using a proxy. (Basically you add the correct headers to your requests and replies.)

      Hope this helps.
      Cheers
      Kenny

    • Alex

      Hi,

      “(Basically you add the correct headers to your requests and replies.)”
      below is an example how to add the header to your response:

      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public Response getFooBar() {
      String json = “”{foo: \”bar\”}”;
      return Response.ok(json).header(“Access-Control-Allow-Origin”, “*”).build();
      }

      • Hi Alex, I’have a problem Access-Control-Allow-Origin, and your comment was very ussefull for me!

        Regards

        Note: sorry for my english

      • best place to study http://www.7eleventech.com

  • Pingback: Using Backbone.js with a RESTful Java Back-End()

  • Pingback: Confluence: Mobile Devices Development()

  • Pingback: The LiveCycle Post | Using Backbone.js with a RESTful Java Back-End()

  • Carlos Martins

    Hi Christophe. As always, a great sample! How would you work the authentication and the security layer on the REST?
    How would you work the login in html, and assure that all REST invocations are validated and are secure?
    Regards

  • MeanHouse

    Hi,

    At first let me thank you for putting the nicest example of Webservice that is done using REST/Jersey.
    However, my question is not regarding the service, but in database connectivity. You have used mysql as your database and so on, I would like to use Oracle, but the problem with the connection string,
    my database name is, Orcl, name: system and password: sa1234, but don’t what would be the syntax for putting the data.

  • MeanHouse

    Hi,

    At first let me thank you for putting the nicest example of Webservice that is done using REST/Jersey.
    However, my question is not regarding the service, but in database connectivity. You have used mysql as your database and so on, I would like to use Oracle, but the problem with the connection string,
    my database name is, Orcl, name: system and password: sa1234, but don’t what would be the syntax for putting the data. Can you please share your thoughts, how i can use Oracle database connectivity in your code.

  • Pingback: One Java Service POJO for AMF/XML/JSON with Spring BlazeDS & Jersey JAX-RS | Web App Solution Blog()

  • DS

    Awesome Example !!!!!! Helped me a lot … Thanks,Thanks,Thanks,Thanks. :-)

  • Tamil

    Hi,
    Thanks for a simple and elegant example for RESTful service. I have one question,
    what if the ‘Wine’ object is modified later and a group of people need the initial version of ‘Wine’ and a different group need the newer version of ‘Wine’?
    Bottomline, how to deal with versions of ‘Wine’ object? I hate to use query params, that may not be valid for POST, I might use PUT instead, still not an elegant solution.
    Your advise please.

    Thanks much,
    Tamil

  • Shailendra kumar

    Really good article. Thanks for this article and the source code. The example application worked like a charm.

  • Ashu sharma

    I can’t make this example run beyond the static index.html and main.js. I tried in Eclipse and then in NetBeans with both Tomcat and Glassfish. There seems to some errors in terms of URIs for the RESTFul Webservices. Context was not setup in Glassfish and Tomcat is also not going any further.
    I like the example and there is no compilation errors but some how it needs a lot of work around to make it run end to end.

  • Larry

    I deployed to tomcat, and no data populated the web page.

    Did I dod something wrong?

  • nick

    Bit of a simple question, but how do you open the java project in eclipse (do I need to create a project and import the files)

    thanks
    Nick

  • Pingback: Rest webservice Jersey Backbone jquery « Life in USA()

  • Pingback: Backbone.js and Twitter Bootstrap tutorials - Adriel Blog | Adriel Blog()

  • Ahaa, its nice discussion on the topic of this piece of writing at this place at this blog,
    I have read all that, so now me also commenting at this place.

  • Good Job Christophe :)… I am waiting Your article about security concerns about REST/JSON

    • Best Place to study JAVA , Hadoop is 7Eleven Arthashastra.

  • Maran

    Hi,
    I am a newbie to jquery and I tried the eclipse project and configure my database as defined in the readme file.
    But while creating a ‘New Wine’ i got this error “addWine error: error”. Need help…

  • Tim

    Awesome tutorial, thank you!

  • Mahadevan

    Thanks for providing this example and the example looks nice. But I am able to get the proper output when I use get or delete. But for post or put I am getting problem. When I send the json form using, json.stringify(), the service is not taking up the json, I am sending and I am getting an error message. Can someone who has run this successfully help me send me the code with which he is successful? Thanks in advance,

  • Mahadevan

    I have managed to workout the needful to get the example working. But I needed to make some modifications. Thanks for providing this example.

  • kaneyip

    really appreciate the code especially for new beginner like me…thanks alot

  • Pingback: Creating a REST API using Node.js, Express, and MongoDB()

  • Gian

    Hi,
    I have a problem with fields on the DB that contain the underscore “_” character in the field name.
    Jersey seems to ignore those fields and no data is stored on the DB …
    Any suggestion ?

  • al

    Hi Christophe, the code highlighter doesn’t work properly on the entire website including all ther posts, wanted to let you know.

  • Nice post.

    If you wanted to have a slightly more ‘RESTful’ API you could implement the search functionality with query params on the Wine resource like so:

    /api/wines?name=*Chateau*

    Style wise /api/wines/search is more of an RPC approach then a RESTful one.

    • Mars009

      Thanks for the great tutorial! I have a quick question though, how are the js files and html files being loaded into the browser? Setting the src of the is caught by the servlet and prepends the request for the resources.

  • Jack Rooney

    Hi Christophe ,

    Thanks a lot for the wonderful article. However, i have a question. when I issue a POST using the curl command that you have listed, it gives me a HTTP 1.1 404 Not Found error. Can you kindly have a look into this and let me know.

    Thanks again for this wonderful tutorial.

    Regards,
    Jack

  • Avivkri

    Great example. Helped me a lot in doing a restful service application

  • Luis

    It works! Simple and clear!

    Thanks!

  • Gopal

    is it possible to send custom object as a @Pathparam using get method and i need json as output using RESTFUL.

    I mean instead of sending all the parameters URI like —-> custom/1/aaa/addr shall we custom/pojo

    Client Side:

    class Pojo{
    int id=1;
    String name=”aaa”;
    String addr=”addr”;
    //setter & getters

    }

    Main class:

    public static void main(String… a)
    {
    Pojo pojo = new Pojo();

    System.out.println(service.path(“rest”).path(“custom/pojo”).accept(MediaType.APPLICATION_JSON).get(String.class));
    }

    server side:

    @Path(“/custom”)
    class Custom
    {
    @GET
    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
    @Path(“{pojo}”)
    public Pojo getJsonOutput(@PathParam(“pojo”) Pojo p) {
    if(1==p.getId() && “aaa”.equals(p.getName()) && “addr”.equals(p.getAddr())

    return new Pojo();

    else

    return null;
    }
    }

    class Pojo{
    int id=1;
    String name=”aaa”;
    String addr=”addr”;
    String firstName=”aaa”;
    String lastName=”bbb”;
    String firstAddr=”ccc”;
    String lastAddr=”ddd”;
    String mobnumber=”123457896″;

    //Setters & Getters

    }

  • Raju

    Hi, nice t utorial. But my request is can u provide this example using spring3. I am gladful if u give me spring 3 hibernate mysql restful webservices (jquery and javascript not necessary)

  • Zim

    Excellent tutorial, really good for those who have everything in place but need an example that plugs it all together

  • I got this web site from my pal who told me about this site and at the moment this
    time I am browsing this site and reading very informative articles here.

  • Hello mates, nice post and fastidious urging commented here, I am actually enjoying by these.

  • Santiago H

    Hi im not sure but how can I implement MVC with rest? can I use push or pull?

    Thanks in advance

  • imomi

    Can I perform partial updates to the Wine object?

    For example: return JSON.stringify({
    “id”: $(‘#id’).val(),
    “name”: $(‘#name’).val(),
    “grapes”: $(‘#grapes’).val()
    });

  • Hi All ,
    Is there any way to pass multiple json objects from jquery to call a rest service method that has multiple parameter.

    eg :
    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Wine compareWine(Wine wine1 , Wine wine2) {
    return dao.create(wine1);
    }

  • regow

    Thank you, for your tutorial. I am using jquery dataTables, how can I persuade Jersey to provide data in a format like this:
    { “aaData”: [
    [ “A”, “Internet Explorer 4.0”, “Win 95+”, 4, “X” ],
    [ “B”, “Internet Explorer 5.0”, “Win 95+”, 5, “C” ] ] }
    which is the format that dataTables requires.

  • It’s impressive that you are getting ideas from this article as well as from our dialogue made at this place.

  • It’s really a nice and useful piece of info. I’m
    glad that you simply shared this useful information with us.
    Please keep us up to date like this. Thanks for sharing.

  • I don’t know if it’s just me or if perhaps everybody else experiencing issues with your blog.
    It appears like some of the text on your posts are running off the screen.
    Can somebody else please provide feedback and let me know if this is
    happening to them as well? This could be a problem with
    my browser because I’ve had this happen before. Appreciate it

  • Fantastic blog! Do you have any suggestions for aspiring writers?
    I’m planning to start my own blog soon but I’m a little lost on
    everything. Would you advise starting with a free platform
    like WordPress or go for a paid option? There are so many choices out there that I’m totally confused .. Any recommendations? Many thanks!

  • My relatives always say that I am wasting my time here at
    net, except I know I am getting familiarity everyday by reading
    such good content.

  • Hello, just wanted to mention, I enjoyed this article.
    It was inspiring. Keep on posting!

  • Pingback: JAX-RS Form Validation -Highlight input text field and display validation message | BlogoSfera()

  • Ahmad

    Can you please guide me how can I place the Jersey implementation JAR’s out of the project? I mean can I place these jars on a common path for all the JAX-RS web services I have?

  • Xplorer

    its a beautiful example ….. tests r running great but i m unable 2 run the Jquery client … is there any errors… i m not geting the list of wines … help wud b apppreciable

  • Truly no matter if someone doesn’t know afterward its up to other viewers that they will assist, so here it occurs.

  • I every time used to read piece of writing in news papers but
    now as I am a user of internet therefore from now I am using net
    for articles, thanks to web.

  • cashew

    Hi,
    this is a great tutorial which helps me developing a web service.
    I could adapt your example very well, but i despair of one single (and surely easy) thing:
    How can i change the “subfolder” cellar to anything or to nothing:

    for example:
    old: localhost:8080/cellar/xyz….
    new1: localhost:8080/roof/xyz…
    new2: localhost:8080/xyz…

    Thanks in advance,
    and keep your blog alive :)

  • What’s up, of course this paragraph is genuinely fastidious and I have learned lot of things from it concerning blogging. thanks.

  • Hi there! Do you know if they make any plugins to assist with
    Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good gains.

    If you know of any please share. Thank you!

  • Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot
    you an email. I’ve got some creative ideas for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it improve over time.

  • I bought the machine on line and finding the coupon and testing it before final payment cost me
    less than 15 minutes. Check what type of promotions and discounts are available in their website and decide which type of coupons
    you can use. If we are going for an offline shopping and
    if we don”t find the specified product then we may not shop in such cases.

  • Hi there I am so thrilled I found your weblog, I really
    found you by error, while I was browsing on Askjeeve for something else, Anyhow I am here now and would just like to say
    thanks for a fantastic post and a all round exciting blog
    (I also love the theme/design), I don’t have time to browse it all at the minute but I have saved it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the great work.

  • Pretty component of content. I simply stumbled upon your blog and in accession capital to claim that I get in fact loved account your weblog posts. Any way I’ll be subscribing to your feeds and even I fulfillment you get right of entry to consistently fast.

  • Pingback: RESTful services with jQuery and Java using JAX-RS and Jersey | Christophe Coenraets | InhumanBlog()

  • I’m curious to find out what blog platform you’re utilizing?
    I’m experiencing some minor security problems with my latest website and I’d
    like to find something more risk-free. Do you have any recommendations?

  • Priyanka

    hi Christophe,

    Your code is working fine but if i separate the web service code from the front end, the response from the web service in the JSON format is not coming. my requirement is to test if web service and front end projects are deployed on different servers, then how to make them work. Note: html page is able to consume webservice but response is not getting rendered on the page. Please help me.

    Thanks in advance.

  • Priyanka

    Hi Alex,

    Thanks for the post.With your example i am able to run Get Request in cross-site.but still facing problem to save data through POST request.Below is the code which i changed to run GET request for cross-site problem.
    @GET
    @Produces({ MediaType.APPLICATION_JSON })
    public Response findAll() {
    System.out.println(“findAll”);
    return Response.ok(dao.findAll()).header(“Access-Control-Allow-Origin”, “*”).build();
    }
    but POST is still not working with this change. Please help.

  • Pingback: How to consume RESTful Services using jQuery and/or Javascript | Share your knowledge()

  • I couldn’t refrain from commenting. Exceptionally well
    written!

  • i enjoyed this article.
    thanks for sharing the info

  • Query about java for me its cleared, thanks

  • govahma

    thanks for nice and clean example, i had tried this,all things are gone fine and i was able to access service in localhost:8080 but once i change the url to 192.168.1.17:8080 which is the ip of system i am not able to access the service and getting following line in log.
    INFO: Couldn’t find JAX-B element for class javax.ws.rs.core.Response
    any clue.

  • Jen

    This is a great article and your code sample on Github helped me immensely.

    Thank you so much!

  • Dear Chris,

    Thanks for detailed explanation of RESTful services with jQuery and Java. Looking forward more tech articles from you.

  • Ahmed

    how can i upload image while defining new wine , on another words who can i upload file while submitting ajax request with wine object

  • srikanth

    Hi All,

    When i am running this application with the url “localhost:8080/cellar/rest/wines”, the output is coming as an xml document and the error is showing like this….

    This XML file does not appear to have any style information associated with it. The document tree is shown below.

    Can i know the reason

  • I pay a quick visit everyday some web sites and information sites to read posts, except
    this website presents feature based writing.

  • Wasn’t better to use JPA?! :\

  • Fantastic blog! Do you have any tips for aspiring writers?
    I’m planning to start my own site soon but I’m
    a little lost on everything. Would you recommend starting with a free platform like WordPress or go for
    a paid option? There are so many options out there that I’m completely confused ..
    Any tips? Thanks a lot!

  • I found strange issue – ‘wineDAO’ is allocated (by calling ‘Wine wine = new Wine();’ in WineResources.java file) on every request by ‘curl’ utility.

    I found it by debugging the code in Eclipse.
    Please take a look at the my very basic version (copy-paste by 99%) that has this issue:
    https://github.com/kostaz/WineCellar

    The commit that show the problem is “5700684 Added Java server side – not all works”.

    Below is the Eclipse call stack.

    ################################################################################
    Tomcat v7.0 Server at localhost [Apache Tomcat]
    org.apache.catalina.startup.Bootstrap at localhost:21076
    Thread [main] (Running)
    Daemon Thread [Thread-1] (Running)
    Daemon Thread [ContainerBackgroundProcessor[StandardEngine[Catalina]]] (Running)
    Daemon Thread [http-bio-8080-Acceptor-0] (Running)
    Daemon Thread [http-bio-8080-AsyncTimeout] (Running)
    Daemon Thread [http-bio-8080-exec-1] (Running)
    Daemon Thread [ajp-bio-8009-Acceptor-0] (Running)
    Daemon Thread [ajp-bio-8009-AsyncTimeout] (Running)
    Daemon Thread [http-bio-8080-exec-2] (Running)
    Daemon Thread [http-bio-8080-exec-3] (Suspended (breakpoint at line 12 in WineDAO))
    owns: SocketWrapper (id=72)
    WineDAO.() line: 12
    WineResource.() line: 20
    NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]
    NativeConstructorAccessorImpl.newInstance(Object[]) line: not available
    DelegatingConstructorAccessorImpl.newInstance(Object[]) line: not available
    Constructor.newInstance(Object…) line: not available
    ResourceComponentConstructor._construct(HttpContext) line: 191
    ResourceComponentConstructor.construct(HttpContext) line: 179
    PerRequestFactory$PerRequest._getInstance(HttpContext) line: 182
    PerRequestFactory$PerRequest(PerRequestFactory$AbstractPerRequest).getInstance(HttpContext) line: 144
    WebApplicationContext.getResource(Class) line: 238
    ResourceClassRule.accept(CharSequence, Object, UriRuleContext) line: 83
    RightHandPathRule.accept(CharSequence, Object, UriRuleContext) line: 147
    RootResourceClassesRule.accept(CharSequence, Object, UriRuleContext) line: 84
    WebApplicationImpl._handleRequest(WebApplicationContext, ContainerRequest) line: 1469
    WebApplicationImpl._handleRequest(WebApplicationContext, ContainerRequest, ContainerResponse) line: 1400
    WebApplicationImpl.handleRequest(ContainerRequest, ContainerResponse) line: 1349
    WebApplicationImpl.handleRequest(ContainerRequest, ContainerResponseWriter) line: 1339
    ServletContainer$InternalWebComponent(WebComponent).service(URI, URI, HttpServletRequest, HttpServletResponse) line: 416
    ServletContainer.service(URI, URI, HttpServletRequest, HttpServletResponse) line: 537
    ServletContainer.service(HttpServletRequest, HttpServletResponse) line: 708
    ServletContainer(HttpServlet).service(ServletRequest, ServletResponse) line: 727
    ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 303
    ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 208
    WsFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 52
    ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 241
    ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 208
    StandardWrapperValve.invoke(Request, Response) line: 220
    StandardContextValve.invoke(Request, Response) line: 122
    NonLoginAuthenticator(AuthenticatorBase).invoke(Request, Response) line: 501
    StandardHostValve.invoke(Request, Response) line: 170
    ErrorReportValve.invoke(Request, Response) line: 98
    AccessLogValve.invoke(Request, Response) line: 950
    StandardEngineValve.invoke(Request, Response) line: 116
    CoyoteAdapter.service(Request, Response) line: 408
    Http11Processor(AbstractHttp11Processor).process(SocketWrapper) line: 1040
    Http11Protocol$Http11ConnectionHandler(AbstractProtocol$AbstractConnectionHandler).process(SocketWrapper, SocketStatus) line: 607
    JIoEndpoint$SocketProcessor.run() line: 313
    ThreadPoolExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: not available
    ThreadPoolExecutor$Worker.run() line: not available
    TaskThread(Thread).run() line: not available
    C:\Program Files\Java\jre7\bin\javaw.exe (May 9, 2014, 9:27:16 PM)
    ################################################################################

  • Thanks for the this informative article. Looking forward more tech articles from you.

  • vikash kumar

    Lovely and valuable, excellent and mind blowing blog.

    I got a lot of knowledge from your blog love this and study your blog and helped me a lot for more knowledge about web development.

    Thank you so…. so much..

  • Do you have a spam problem on this website; I also am a blogger, and I was wondering your situation;
    we have developed some nice practices and we are
    looking to swap techniques with others, why not shoot me
    an e-mail if interested.

  • Whats upp are using WordPress for your site
    platform? I’m new to the blog world but I’m trying tto
    get started and set up my own. Do you need
    any html coding knowledge to make your own blog? Any help would be greatly
    appreciated!

  • Find Best IT Training Institutes Information @ http://www.itsikshana.com

    regards
    ramesh

  • Pingback: Node.js Sunday Reading | emun(eee)()

  • Bartholomew

    Please Chritopher ,i must appreciate your work its awsome .i tried it ,it worked .but how can i post or put an image file,or pdf file.how can i GET an image file or dpf file ? please i need your help i have been trying that for so long now Christopher.please help me.

  • Bartholomew

    Please Christopher ,i must appreciate your work its awesome .i tried it ,it worked .but how can i post or put an image file,or PDF file.how can i GET an image file or PDF file ? please i need your help i have been trying that for so long now Christopher.please help me.tks

  • contact..www.7eleventech.com

  • nice article to study …. people who really cant understand about mobile application webdevelopmen can probaly go for class room training ….
    best place to study 7eleven technologies…

    contact
    http://www.7eleventechnologies

  • nice place to study http://www.7eleventech.com

  • good place to study

  • best place to study http://www.7eleventech.com

  • nice article mr.rok… good please to study .thaks to 7eleventech.com

  • Best place to study JAVA Hadoop technology is 7Eleven Arthashastra

  • This is a very good article to study.If anybody intersted to update with the knowledge in this concept can choose a best institute in chennai … The best institute in chennai 7eleven technologies.. They provide with a good training with real time exposure.. They are also doing with a assured placement..
    http://www.7eleventech.com

  • Snehal

    sir could u explain how to do basic authentication part using jersey rest webservice.means user can maintain his session to every page.

  • JB

    Very nice! Congratulations and Thanks for sharing!

  • GET,POST,PUT and DELETE .All four of these HTTP methods are supported by web services that are considered RESTful—applications.GET and POST are universally supported by web browsers.PUT and DELETE, unfortunately, are not.

  • Pingback: Create RESTful API / Web Service with Slim, PHP and MySQL | free pdf download()

  • Looking forward more tech articles from you.

  • rohan

    1000 likes very good application

  • Pingback: Spring: Consuming a RESTful Web Service with jQuery | Wanderer()

  • Hey, I just wanted to personally thank you for taking your time to leave Your valuable post.i tried it ,it worked .. Eagerly waiting for ur next post. thanks and congrats!!

  • They provide with a good training with

  • Andrey

    Excellent article !!! Thank you. This article has helped in the development of JSON + JQuery very much.

  • nice one like it

  • Narasimha

    thanks a lot

  • Amber

    Thank you this is very helpful!

    • burak

      Can you help me please, I can’t run the jquery part of the project. Restful api works fine, mysql datas are fine. But index.html still doesn’t show wines. skype:burak.erkan mail:burakerk@hotmail.com
      If any one helps I will be glad.

      • burak

        I found the problem, If you create project some other names project fails. Because in main.js ‘rootURL’ is hardcoded. Be careful about that. =) Thanks to Christophe Coenraets, its very good example.

  • Pingback: Creating a REST API using Node.js, Express, and MongoDB | Share For Life()

  • I have read your blog and I got very useful and knowledgeable information from your blog. It’s really a very nice article. You have done a great job

  • Formalarımızda kullandığımız kumaş; birinci sınıf mikro-interlok olup; esnek-fit, anti-bakteriyel, termo-balans ve hemen kuruma özelliğine sahiptir. Futbol maçlarınızda size hareket özgürlüğü sunan bu formalar; günlük olarak giyilebilecek kadar şık tasarlanmıştır.

  • kalite,fiyat uygunlugu ve imalattan.profesyonel ekip eşliğinden güvenilir işler yapılmaktadır

  • Hey thanks so much this is a very useful information.!!

    Regards,
    Angel Banuelos.

  • It is an amazing post. Very useful to me. I liked it .

  • moritz

    Very usefull. Explanation very accurate (short, precise and targeted).
    Thank you very much.

  • That the information was very very excellent and get more information after refer that the site,thanks for share that post and the all articles was very easily understand and get more information,then the coding very nice easy understand and this is best one aticle.

  • SAP ABAP Training Institutes in Noida-Webtrackker is an it company and also provide the SAP ABAP trainng by real time working expert trainer to their students,if you are looking the”sap abap training in noida,SAP ABAP training institute in Noida,SAP ABAP Coaching in Noida,sap-abap training institutes noida, best SAP ABAP training center in noida,sap abap certification training noida,sap abap training and placement in noida,delhi”and placement in noida then Webtrackkeris the best option for you.

  • SAP BASIS training institute in Noida-Webtrackker is an it company and also provide the SAP

    BASIS trainng by real time working expert trainer to their students,if you are looking the”sap BASIS training in noida,SAP BASIS Coaching in Noida,SAP BASIS training

    institute in Noida,Sap-BASIS training institutes noida,best SAP BASIS training center in noida,sap BASIS certification training noida,sap BASIS training and placement in

    noida”and placement in noida then Webtrackker is the best option for you.

  • php training institute in noida -Webtrackker is an it company and also provide the php trainng by real time working expert trainer to their students,if you are looking the “Php Training In Noida, php training institute in noida, best Php Training institute In Noida, php coaching institute in ghaziabad, Php Training Institute in noida, php coaching institute in noida, php training institute in Ghaziabad, php training institute, php training center in noida, php course contents, php industrial training institute in delhi, php training coaching institute, best training institute for php training, top ten training institute, php training courses and content” and placement in noida then Webtrackker is the best option for you.

  • Java training institute in noida-webtrackker is best java training institute in noida witch also provides real time working trainer, then webtrackker best suggestion of you and better carrier if you are looking the”Java Training in Noida, java industrial training, java, j2ee training courses, java training institute in noida, java training center in delhi ncr, java training institute in ncr, Ghaziabad, project based java training, institute for advance java courses, training institute for advance java, java industrial training in noida, java/j2ee training courses in ghaziabad, meerut, noida sector 64, 65, 63, 15, 18, 2″Webtrackker is best otion for you.

  • Best hadoop training institute in Noida- with 100% placement support – Fee Is 15000 Rs – web trackker is the best institute for industrial training institute for hadoop in Delhi, Ghaziabad, if you are interested in hadoop industrial training then join our specialized training programs now. hadoop Training In Noida, hadoop industrial training in noida, hadoop training institute in noida, hadoop Training In ghaziabad, hadoop Training Institute in noida, hadoop coaching institute in noida, hadoop training institute in Ghaziabad.hadoop training Institute in Noida

  • Sas training institutes in noida – best sas training institute in noida and provides real time working trainer. web trackker is the best institute for industrial training institute for sas in noida, Ghaziabad, if you are interested in sas industrial training then join our specialized training programs now.”SAS Training In Noida, SAS industrial training in noida, SAS training institute in noida, SAS Training In ghaziabad, SAS Training Institute in noida, SAS coaching institute in noida, SAS training institute in Ghaziabad, sas training institute, sas training center in noida, sas course contents, sas industrial training institute in delhi, SAS training coaching institute, best training institute for SAS training, top ten training institute, sas training courses and content”

  • php training institute in noida – Best Php Training Institute Noida PHP is a server side scripting language designed for web development but also used as a general purpose programming language. php training in Noida with 100% placement support.you are interested in php industrial training then join our specialized training programs now.”Php Training In Noida, php training institute in noida, best Php Training institute In Noida, php coaching institute in ghaziabad, Php Training Institute in noida, php coaching institute in noida, php training institute in Ghaziabad, php training institute, php training center in noida, php course contents, php industrial training institute in delhi, php training coaching institute, best training institute for php training, top ten training institute, php training courses and content”/>

  • php training institute in noida – Best Php Training Institute Noida PHP is a server side scripting language designed for web development but also used as a general purpose programming language. php training in Noida with 100% placement support.you are interested in php industrial training then join our specialized training programs now.”Php Training In Noida, php training institute in noida, best Php Training institute In Noida, php coaching institute in ghaziabad, Php Training Institute in noida, php coaching institute in noida, php training institute in Ghaziabad, php training institute, php training center in noida, php course contents, php industrial training institute in delhi, php training coaching institute, best training institute for php training, top ten training institute, php training courses and content

  • sas training institute in noida – web trackker is the best institute for industrial training for SAS in noida,if you are interested in SAS industrial training then join our specialized training programs now. webtrackker provides real time working trainer with 100% placment suppot.

  • Wow! This three part tutorial helped me a lot. Thanks for sharing your ideas. =)

  • Awesome post.

  • Linux training institute in noida – Webtrackker noida provides

    best class linux trainer with 100% placement support. webtrackker best training institute

    in noida provides all IT course like JAVA, DO NET, SAP, SAS, HADOOP, PHP, ORACLE APPS,

    ORACLE DBA, LINUX, MOBILE APPS, SOWFTWERE TESTING, WEB DESIGNIG.

  • Brajesh

    first of all thanks to give useful information to given by u,and i want to complete example of ,ui,rest ,service and dao .

  • Jagadeesh

    Hey Superb one. Thanks

  • Pingback: WildFly 8 | lababidy()

  • Thomas

    Fantastic! I have been looking exactly for this for some days now. But there is no single example/tutorial with a working restful server AND a html/javascript client that actually works.

  • Great Article shared!! Keep posting. http://www.margonline.com/

  • rakesh

    Hadoop training in hyderabad.All the basic and get the full knowledge of hadoop.
    hadoop training in hyderabad

css.php