The Java EE 6 Tutorial, Volume I

Overview of a Jersey-Annotated Application

The following code sample is a very simple example of a root resource class using JAX-RS annotations. The sample shown here is from the samples that ship with Jersey, and which can be found in the following directory of that installation: jersey/samples/helloworld/src/main/java/com/sun/jersey/samples/helloworld/resources/

package com.sun.jersey.samples.helloworld.resources;


// The Java class will be hosted at the URI path "/helloworld"
public class HelloWorldResource {
    // The Java method will process HTTP GET requests
    // The Java method will produce content identified by the MIME Media
    // type "text/plain"
    public String getClichedMessage() {
        // Return some cliched textual content
        return "Hello World";

The following sections describe the annotations used in this example.