The following code is the contents of the com.sun.jersey.samples.helloworld.resources.HelloWorldResource class:
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.Path;
@Path("/helloworld")
public class HelloWorldResource {
@GET
@Produces("text/plain")
public String getClichedMessage() {
return "Hello World";
}
}
In this example, the following annotations are processed at runtime:
The @Path annotation specifies that the Java class will be hosted at the URI path /helloworld.
The @GET annotation specifies that the Java method will process HTTP GET requests.
The @Produces annotation specifies that the Java method will produce content identified by the MIME media type text/plain.