JAX-RS REST @Consumes Example

Previously we have learnt about how to produce different types of responses using @Produces annotation, In this article we will learn how to consume different types of request from the user using @Consumes annotation.

@Consumes annotation is used to specify the MIME media types that a resource can consume. @Consumes can be applied at both class level and method level, If applied on class level all the methods can produce the specified MIME types by default. If it is applied at the method level, it overrides any @Consumes annotations applied at the class level.
[Read more…]

JAX-RS REST @Produces Example

Previously we have learnt about how to get parameters using @PathParam, @QueryParam, @Context, @FormParam@MatrixParam annotations, In this article we will learn how to send different types of response back to the user using @Produces annotation.

@Produces annotation is used to specify the MIME media types that a resource can produce and send back to the client. @Produces can be applied at both class level and method level, If applied on class level all the methods can produce the specified MIME types by default. If it is applied at the method level, it overrides any @Produces annotations applied at the class level.
[Read more…]