Planning JAX-RS web applications
Subtopics
- Plan to use JAX-RS to enable RESTful services
- Define the resources in RESTful applications
RESTful services are based on manipulating resources. Resources can contain static or dynamically updated data. We define resources in applications, and make them available as REST services.
- Define the URI patterns for resources in RESTful applications
Representational State Transfer (REST) services are based on manipulating resources. Resources for RESTful services are addressable via URLs.
- Define resource methods for RESTful applications
Individual resources can define their capabilities by using supported HTTP methods. In Representational State Transfer (REST) services, the supported methods are GET, PUT, DELETE, and POST. All operations are typically conducted by using one of the predefined HTTP methods with a resource.
- Define the HTTP headers and response codes for RESTful applications
HTTP headers and status codes are useful to help intermediary and client programs understand information about requests and responses for applications. HTTP headers contain metadata information. HTTP status codes provide status information about the response.
- Define media types for resources in RESTful applications
Resources are represented by multiple formats. XML, JavaScript Object Notation (JSON), Atom, binary formats such as PNG, JPEG, GIF, plain text, and proprietary formats are used to represent resources. Representational State Transfer (REST) provides the flexibility to represent a single resource in multiple formats.
- Define parameters for request representations to resources in RESTful applications
Use parameters as part of the URL or in the headers. Path parameters, matrix parameters, query parameters, header parameters, and cookie parameters are useful for passing in additional information to a request.
- Define exception mappers for resource exceptions and errors
The default behavior is to use the exception handling functionality of the application container such as JSP error pages. However, we can customize the error handling and send specific responses back when an exception or error occurs.