What is the use of @Produces("application/pdf") in real time ?

While going through the basics of rest web services I have seen the use of Download Files from (JAX-RS) RESTful Web Service.
Can some one please let me know the actual use of
@Produces(“text/plain“)
@Produces(“image/your image type[.jpg/.png/.gif]”)
@Produces(“application/pdf“)

Replies

  • Jason Estibeiro
    Jason Estibeiro
    The #-Link-Snipped-# annotation is used to specify the MIME media types of representations a resource can produce and send back to the client. Also, in the response sent back to the client the response header `Content-Type` is set to the MIME type passed to the annotation.

    So,
    @Produces(“text/plain“) 
    will generate a response which will contain just plain text.

    @Produces(“application/pdf“)
    will generate a response with a document in .pdf format.

    This documentation #-Link-Snipped-# has explained it very well. Do have a look at it.
  • Roshni Prasad
    Roshni Prasad
    Jason Estibeiro
    The #-Link-Snipped-# annotation is used to specify the MIME media types of representations a resource can produce and send back to the client. Also, in the response sent back to the client the response header `Content-Type` is set to the MIME type passed to the annotation.

    So,
    @Produces(“text/plain“) 
    will generate a response which will contain just plain text.

    @Produces(“application/pdf“)
    will generate a response with a document in .pdf format.

    This documentation #-Link-Snipped-# has explained it very well. Do have a look at it.
    Hi Jason,
    Thanks for the reply.
    I would like to tell you that I am aware of the basic usage of @Produces.
    What I wanted to know is can we use @Produces(“application/pdf“) in-order to convert a java object to PDF file?

You are reading an archived discussion.

Related Posts

Entrepreneurship is all about taking control of your own destiny and becoming a problem solver. Hari Prashath M, founder of Triton IT Solutions had humble beginnings as a son of...
Senior author, Xiangdong Yao and his subordinates at Griffith’s Queensland Micro- and Nanotechnology Centre were successful in replacing platinum as an electro-catalyst for hydrogen preparation from water. The team considers...
Guys! 27/03/16 is the last date for submission of application. All the best!!!
Mahindra and Mahindra Ltd. is all set to launch their latest offering, a SUV named NuvoSport. In the latest press release, the company claimed that the car sports a bold...
Gaming softwares in the field of medical science talk about a new technical blend that supports both the industries. A group of researchers from the Institute of Digital Healthcare, WMG...