In my previous article we have learnt how to use @Produces annotation. We have produced either xml or json response but not able to produce both xml and json in a single method. In this example we will learn how to produce multiple media type response depending upon the clients request we will produce response, lets see how we can achieve it. [Read more…]
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.