From the course: Jakarta Web Services

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Media types in action

Media types in action - Jakarta EE Tutorial

From the course: Jakarta Web Services

Media types in action

- [Instructor] Let's first start by inspecting a REST endpoint and see what the HTTP response headers look like. In my REST client, I have this endpoint. If I inspect the headers for this endpoint, you can see the response headers like this. Let's go to headers. Notice the Content-Type response header. It has a value of application/json. This means that this REST endpoint returns the requested resource in JSON format. Notice that I have not declared the media types acceptable for the resource method getFlightsByAirline to return using the @Producers annotation. However, since my return Java type is a list of flight objects, in the absence of the annotation, it is mapped by the message body writer to the response entity in JSON format. That's because Jakarta REST determines that it's the applicable media type for the content returned and this is why you saw the Content-Type as application/json. Let's look at this…

Contents