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

    Updated: Oct 26, 2024
    Views: 1.3K
    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“)
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Jason Estibeiro

    MemberMar 22, 2016

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Roshni Prasad

    MemberMar 28, 2016

    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?
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register