Java Reference
In-Depth Information
}
@Path("{lastname}")
public final class EmpDetails {...}
The following code snippet shows this JAX-RS resource class converted to a CDI bean.
The beans must be proxyable, so the
Employee
class requires a non-private constructor
with no parameters, and the
EmpDetails
class must not be
final
.
@Path("/employee/{id}")
@RequestScoped
public class Employee {
public Employee() {...}
@Inject
public Employee(@PathParam("id") String id) {...}
}
@Path("{lastname}")
@RequestScoped
public class EmpDetails {...}
Conditional HTTP Requests
JAX-RS provides support for conditional GET and PUT HTTP requests. Conditional GET
requests help save bandwidth by improving the efficiency of client processing.
A GET request can return a Not Modified (304) response if the representation has not
changed since the previous request. For example, a web site can return 304 responses for
all its static images that have not changed since the previous request.
A PUT request can return a Precondition Failed (412) response if the representation has
been modified since the last request. The conditional PUT can help avoid the lost update
problem.
Conditional HTTP requests can be used with the
Last-Modified
and
ETag
headers.
The
Last-Modified
header can represent dates with granularity of one second.
@Path("/employee/{joiningdate}")
public class Employee {
Date joiningdate;