JAX – RS @PathParam Annotation – Restful Example in Java

In this tutorial we will learn how @PathParam annotation will work in JAX – RS . Let us have a look in to the below example.

Here we are using Jersey 2.0 framework to implement below example. we are using Eclipse to develop this example application.

1. Create Dynamic web project in Eclipse.

restfulparamexamplejersey_project

2. Write Java service class.

 

3. Configure the Jersey Container in web.xml

Configure the Jersey Frame work ServletContainer in web xml and configure the java service classes under it by using <init-param> tag.

 

4. Run the Example

.

Deploy the applicaytion in tomcat  and,use the below url to access the param service.

http://localhost:8080/RestfulParamExample/rest/restparam/Ramesh  

in the above url we are passing parameter ” Ramesh” which will be injecting to {param}  element which is configured with @path annotation.

 

OUT PUT:

restfulparamexamplejersey

 

NOTE : I have not included all the required jersey jars in the source code please download it from here and copy to lib folder.

 

Download  Source Code

 

 

Posted in webservices and tagged , , , , , , , .

One Comment

  1. I think the admin of this web page is genuinely working hard in favor
    of his website, because here every information is quality based data.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">