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.

Add path paramaters

Add path paramaters

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

Start my 1-month free trial

Add path paramaters

- [Instructor] Okay, so let's create a method that retrieves a book based on this ISBN. I'll call this method getBookByIsbn, and the path variable is going to be called ISBN. So, it's going to be a public method, it's going to return a response object, as before. And we're going to simply call it getBookByIsbn. And we're gonna have a path variable which we are going to be making final. We're gonna use the path parameter here, and we're going to use the variable ISBN. And I'll show you how to program that part in a moment. And we're gonna parse that through as a string to a variable, I'm going to call it ISBN, okay. Now that I set the path annotation and parsed the regular expression, we're gonna add path and we're simply going to parse it at a regular expression. As you can note here, the name of the variable is ISBN, and the regular expression follows the name of the variable. And the variable ISBN matches with the variable name in the path parameter. And don't forget, we need to…

Contents