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.

Path parameters

Path parameters

From the course: Java EE: RESTful Service with JAX-RS 2.0

Start my 1-month free trial

Path parameters

- [Narrator] So far, we have seen how to annotate resource methods with HTTP methods GET and POST, But there are more HTTP methods than just those. We have a whole list of those methods on the screen here. However, in the bookshelf application, we're only going to use GET, POST, DELETE, and PUT. We have seen that a resource method can accept two resource instances as a parameter. This resource instance is created from an HTTP body of a POST request. It is deserialized from the JSON payload of the HTTP Body, to a book instance, which can then be persisted in the persistence layer of the application. Now is a good time to talk about path parameters. So, what are path parameters? Well, they are variables that are embedded in the URI. As an example, consider the URI that you see here. It has a variable, 123456789 embedded in it and in this case, it happens to be an ISBN of a book. And what we want to do here is to retrieve it and use it. If this is a GET request, the REST API should…

Contents