Response handling

Topics 

  • Two schemes of generating responses 
    • Creating responses using built-in Entity Provider (Content-handler) 
    • Creating responses using ResponseBuilder 
  • XML content handler via JAXB 
  • JSON content handler 
  • JAXBElement 
  • Creating response for “Create” operation 
    • Set Location response header with the URI of the newly created item 
  • Other built-in Entity Providers

Two Options of Creating a Response 

  • Option #1: Using built-in Entity Provider (Content handler) 
    • Entity providers supply mapping services (marshalling and unmarshalling) between representations such as XML or JSON and their associated Java types 
    • JAX-RS runtime comes with built-in Entity providers for XML 
    • Entity provider (content handler) for JSON is supported by either Jackson or MOXy 
    • Custom entity provider can be plugged in 
  • Option #2: Creating Response object manually 
    • Used when fine-grained control on creating response is needed, for example, setting up custom response headers

You must have an active subscription to download PDF and Lab Zip of this course topic.Please click the "Subscribe" button or the "Login" button if you already have an account.

Subscribe     Login