From the course: Java EE: RESTful Service with JAX-RS 2.0
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Build a response
From the course: Java EE: RESTful Service with JAX-RS 2.0
Build a response
- [Speaker] The full responses are very convenient for the quick development of the simple rest API. However, for more complex APIs you'll find that you'll need more control over this behavior and this is where the response builder comes in to it's own. We have already seen how easy and intuitive it is to use, by using it to set values for properties such as the status code and the response body. Let's take a closer look at the response builder and what functionality it offers. We obtain a responsibility instance by calling one of the static method on the response class. Here are some of the static methods. They should be familiar to you as we already used them to set the response codes and response body. Notice that the all retainer response builder instance. We can use the response builder to further refine the response on the client. Let's see some examples. So you can pass a response status code to the status method. Here we are passing the code 204 and calling the build method…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
The HTTP response4m 24s
-
(Locked)
Build a response3m 24s
-
(Locked)
How to handle errors3m 19s
-
(Locked)
Implement an exception manager2m 46s
-
(Locked)
Work with HATEOAS4m 21s
-
(Locked)
HATEOAS and JAX-RS2m 59s
-
(Locked)
Add HATEOAS to the resource10m 33s
-
(Locked)
Challenge: Add exception handlers19s
-
(Locked)
Solution: Add exception handlers1m 2s
-
(Locked)
-
-
-