Skip to Content
RESTful Java with JAX-RS
book

RESTful Java with JAX-RS

by Bill Burke
November 2009
Intermediate to advanced
310 pages
7h 42m
English
O'Reilly Media, Inc.
Content preview from RESTful Java with JAX-RS

Chapter 5. JAX-RS Injection

A lot of JAX-RS is pulling information from an HTTP request and injecting it into a Java method. You may be interested in a fragment of the incoming URI. You might be interested in a URI query string value. The client might be sending critical HTTP headers or cookie values that your service needs to process the request. JAX-RS lets you grab this information à la carte, as you need it, through a set of injection annotations and APIs.

The Basics

There are a lot of different things JAX-RS annotations can inject. Here is a list of those provided by the specification:

@javax.ws.rs.PathParam

This annotation allows you to extract values from URI template parameters.

@javax.ws.rs.MatrixParam

This annotation allows you to extract values from a URI’s matrix parameters.

@javax.ws.rs.QueryParam

This annotation allows you to extract values from a URI’s query parameters.

@javax.ws.rs.FormParam

This annotation allows you to extract values from posted form data.

@javax.ws.rs.HeaderParam

This annotation allows you to extract values from HTTP request headers.

@javax.ws.rs.CookieParam

This annotation allows you to extract values from HTTP cookies set by the client.

@javax.ws.rs.core.Context

This class is the all-purpose injection annotation. It allows you to inject various helper and informational objects that are provided by the JAX-RS API.

Usually, these annotations are used on the parameters of a JAX-RS resource method. When the JAX-RS provider receives an HTTP request, it finds a Java ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

RESTful Java with JAX-RS 2.0, 2nd Edition

RESTful Java with JAX-RS 2.0, 2nd Edition

Bill Burke
RESTful Java Web Services - Third Edition

RESTful Java Web Services - Third Edition

Balachandar Bogunuva Mohanram

Publisher Resources

ISBN: 9780596809300Supplemental ContentErrata Page