Platinum Partner

Sample REST Web Service Application

Step 1: Download cuubez from the Repository

The first step is to download the latest cuubez stable release from:

Maven Repo


Step 2: Add the following libraries to your Web application

Note: No need to add if you use maven dependency

  • com.thoughtworks.xstream
  • commons-logging
  • javax.servlet
  • javassist

Step 3: Define listeners and bootstrap classes

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" xmlns=""





Step 4: Create your first RESTful service

In a REST based architecture everything is a resource. A resource is accessed via a common interface based on the HTTP standard methods (e.g., POST, GET, PUT or DELETE). Every resource should support the HTTP common operations. Resources are identified by global ID's (which are typically URIs). In the first example, we will recall a RESTful Web service which returns a User object when a certain path is request with an HTTP GET:

User object :

public class User {

    private String id;
    private String name;
    private int age;

    public User(String id, String name, int age) { = id;
        this.age = age; = name;

    public String getId() {return id;}

    public int getAge() {return age;}

    public String getName() {return name;}

    public void setId(String id) { = id;}

    public void setAge(int age) {this.age = age;}

    public void setName(String name) { = name;}

REST service class :

public class UserDetail {

    public User getUser(@PathParam(value = "userId")String userId) {
      User user = new User(userId, "jhone", 35);
      return user;

The @Path annotation at class level is used to specify the base URL of the Web service. Then you can assign a @Path annotation at method level to specify the single action you want to invoke.

In this example, if you need to invoke the userDetail service, you have to use the following URL: (we suppose that the web application is named cuubez.war)


would return:

 "name": "jhone",
 "age": 35
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ }}
{{ parent.authors[0].realName ||}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks