tree: e6f3d5aad9518be64d036ed36a7e41ebd3e87d24 [path history] [tgz]
  1. src/
  2. pom.xml
  3. README.MD
examples/simple-console/README.MD

Simple Console Example

This example demonstrates how to develop RESTful web services with the embedded Grizzly server.

Contents

The example consists of three Java classes and one HTML file:

org.glassfish.jersey.examples.console.App

Contains the main function which starts and stops the HTTP server.

org.glassfish.jersey.examples.console.resources.Colours

A resource class that can produce two different representations of a list of colors. The list can be filtered by a client-supplied query parameter. The resource references the Form resource using the Path annotation declared on the Colours.getColours method.

org.glassfish.jersey.examples.console.FormResource

A resource class that produces a form in response to an HTTP GET, processes the content of the form when submitted, and produces a table of the submitted values in respose to the form being posted.

form.html

A static HTML file that is returned by the Form resource.

The mapping of the URI path space is presented in the following table:

URI pathResource classHTTP methods
/formFormGET, POST
/form/coloursColoursGET

Running the Example

Run the example as follows:

mvn clean compile exec:java

This deploys the example using Grizzly container. You can access the application at:

Fill in the form and submit it. Note that the pull-down list of colors is populated dynamically. Enter part of a color name in the hint box to see a filtered list of colors containing the hint.

You can see the complete list of colors at:

Or see only those colors containing the letter ‘r’:

A WADL description may be accessed at the URL: