O'Reilly logo

Java EE 6 with GlassFish 3 Application Server by David R. Heffelfinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Query and path parameters

In our previous example, we have been working with a RESTful web service to manage a single customer object. In real life, this would obviously not be very helpful. A common case is to develop a RESTful web service to handle a collection of objects (in our example, customers). To determine what specific object in the collection we are working with, we can pass parameters to our RESTful web services. There are two types of parameters we can use: query and path parameters.

Query parameters

We can add parameters to methods that will handle HTTP requests in our web service. Parameters decorated with the @QueryParam annotation will be retrieved from the request URL.

The following example illustrates how to use query parameters ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required