How to create simple REST web service using jersey

In this tutorial I will demonstrate you what Rest is and how to develop a simple rest web service in java using jersey. Before moving forward let see what rest is.

  • REST stands for Representational State Transfer. (It is sometimes spelled “ReST”.)
  • It relies on a stateless, client-server, cacheable communications protocol which uses HTTP protocol.
  • REST is a simpler, lightweight alternative to RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, etc). Know more different between Rest and SOAP.

I will use sun’s JAX-RS reference implementation Jersey to demonstrate simple greeting service.
Create new Java EE project in eclipse and add all dependent jar files in classpath. You can download related jars from https://jersey.java.net site.

Your web.xml will look similar to …

Here you can see web.xml contain one servlet named ServletContainer which has url pattern associated to it.

Now write one class which is our main REST web service class.

This REST based web service will be accessable using following URL.

http://localhost:8080/RESTfulTest/rest/greeting/tousif

REST jersey web service

Download

About the Author

has written 68 posts.

I Love Coding, Analyzing, Designing and doing it the right way. I am obsessed about learn anything new daily and sharing what I have learn each Day. This Blog is journey of my Zeal, going through step by step to the mountain of desire to become prefect. Google Wanna Hire me ?

Copyright © 2017 TechZoo - Technology Blog. All rights reserved.
Proudly powered by WordPress. Developed by 7Tech Solutions