This example demonstrates how to develop RESTful web services with the embedded Grizzly server.
The example consists of three Java classes and one HTML file:
com.sun.ws.rest.sample.console.Main
com.sun.jersey.samples.console.resource.Colours
com.sun.jersey.samples.console.resource.Form
form.html
The mapping of the URI path space is presented in the following table:
URI path | Resource class | HTTP methods |
---|---|---|
/form | Form | GET, POST |
/form/colours | Colours | GET |
Run the example as follows:
mvn clean compile exec:java
From a web browser, visit:
http://127.0.0.1:9998/resources/form
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:
http://127.0.0.1:9998/resources/form/colours
Or see only those colors containing the letter 'r':
http://127.0.0.1:9998/resources/form/colours?match=r
A WADL description may be accessed at the URL:
http://127.0.0.1:9998/resources/application.wadl