JAX-RS Hello World Example in Jersey Framework

In this tutorial we will see how to develop simple hello world Restful example in Jersey Framework.

in this tutorial we are using Jersey 2.0

.

1. Create Dynamic web project in Eclipse.

I am not using Maven here, I have uploaded all the required jars with example ,and you can download total application.The project structure will look like as below.

 

restfulexamplejersey_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

In the above java service class we have implemented the service “sayHello” and we can call this service by using below url.

http://localhost:8080/RestHelloworldExample/rest/hello

Here RestHelloworldExample is our application context , rest will matching web.xml , and hello is the actual path configured to invoke “sayHello” service.

OUT PUT:

restfulexamplejersey

 

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 , , , , , , , , .

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="">