Using Jersey-RESTful with Codenvy

Instantly create Jersey  project off a Codenvy Factory:

Developing RESTful Web services that seamlessly support exposing your data in a variety of representation media types and abstract away the low-level details of the client-server communication is not an easy task without a good toolkit. In order to simplify development of RESTful Web services and their clients in Java, a standard and portable JAX-RS API has been designed. Jersey RESTful Web Services framework is open source, production quality, framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference Implementation.
Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides it’s own API that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development. Jersey also exposes numerous extension SPIs so that developers may extend Jersey to best suit their needs.

Create a Project

Login to your codenvy workspace and create a New WAR Project say “jersey”. Project file structure is shown below :

GetImage (5)

Add Dependencies

Specify the below dependencies in pom.xml which are prerequisites. Make sure these jars are included under Maven Dependencies.

GetImage (6)

Pom.xml :

<name> Repository for Maven</name>

Create HelloWorldService Class

In this example, web request from “projectURL/rest/hello/” will match to “HelloWorldService“, via @Path(“/hello”).

And the “{any values}” from “projectURL/rest/hello/{any values}” will match to parameter annotated with @PathParam.

Code Logic :

package com.codenvy;


public class HelloWorldService {

public Response getMsg(@PathParam("param") String msg) {

String output = "Hello " + msg;

return Response.status(200).entity(output).build();



Create index.jsp

Sample index page for the web application giving a sample link (url) to HelloWorldservice created.

<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="460" bgcolor="#EEFFCA">
<tr><td width="100%"><font size="6" color="#008000"><a href="/rest/hello/codenvy">HelloWorldService</a></font></td></tr>

Create web.xml:

<display-name>Restful Web Application</display-name>


Build and Run the application

Upon successful building the application and navigating to url “projectURL/rest/hello/codenvy”, it displays.

GetImage (7)