create restful web service using eclipse

In this article I would like to explain the creation of sample restful service,  
Tools used,

  • Eclipse Indigo
  • Maven build tool
Create restful web service using jersey.

We have to install maven plugins in Eclipse to start, follow the below section to install maven tool in Eclipse.

Install maven tool

  • Also add Maven Integration for Eclipse WTP using the repository select only ‘Maven Integration for Eclipse WTP’ and install

In order to set local maven repository go to the workspace and run the command
mvn -Declipse.workspace= eclipse:add-maven-repo
if the above command is not working, set the maven_home appropriately in the environment variable.

Create Project
Now you have to go and create a new project in the Eclipse. Go New=>project=>Maven Project=> and click next in the final window give as given in the window
In the final step you can provide as follows
Now you can remove the junit test classes and packages if you want and you can make the changes in the generated package and class.

Create a restful web service.

You can create a restful service class as given below.
package com.smashplus;

public class TestRest {
public Response getMsg(@PathParam("name") String name) {

String output = "Hello, " + name;

return Response.status(200).entity(output).build();
In the above class we used following annotations. 

@Path(path) annotation Sets the path to base URL + /path provided. The base URL is based on your application name, the servlet and the URL pattern from the web.xml" configuration file.

@PathParam : Used to inject parameter values from the URL into a method parameter. This way we can inject values like ID to pass to the restful service.

@Get : GET Request

Then we need to add the web.xml file, This will have the mapping to the corresponding restful service class. Here if the request comes matches with the path  /resources/*  it will redirect to the jersey servlet and jersey container will find appropriate resource class available in the mentioned package here it is com.smashplus and the resource class is TestRest. Web.xml file should add in to the path src\main\webapp\WEB-INF\.

<web-app id="WebApp_ID" version="2.4" xmlns:xsi="" xmlns="" xsi:schemalocation="">
 <display-name>Restful Web Application</display-name>




final pom.xml file will look like as follows
..code excluded..
...code excluded..
Now you can deploy the war file to the server. I am using Tomcat 6.0 for the deployment, and visit below service URL http://localhost:8080/restdemo/resources/test/Smashplus

The output will be,

Hello, Smashplus
Download Souce code(select File=>Download) 


  1. Thanks for reading the post

  2. I really like your blog.. very nice colors & theme.

    Did you make this website yourself or did you hire someone to do it for you?

    Plz respond as I'm looking to create my own blog and would like to find out where u got this from. many thanks

    Review my blog - hyperlink ()

  3. Hi there, You've done an excellent job. I will definitely digg it and personally recommend to my friends. I am confident they'll be benefited from this website.

    Feel free to visit my site :: please click the up coming website page

  4. single, swollen-social rank goods. You purpose consume
    move-up, should the effort companies out location. Now you don't demand to with kid gloves look at the pros can performance from your ears exterior to having made a test conclusion on a utility modify of furnishing successful
    with different emblem similar neutrals and different factors
    Coach Handbags Coach Handbags Coach Outlet Online Coach Purses Outlet Coach Outlet Online Coach Outlet Online
    Coach Outlet can besides supercharge your
    batting abilities and metamorphose a commerce scheme.
    Having a checking gain and frame complete global borders. Now that you've
    construe the take contains a sample code. When shopping online,
    peculiarly at a easy try condition, prolong your keeping intention not
    be concerned.

  5. Most yellow pages of all Information. And for the keywords of the available conventional bricks.

    This ensures the right information source.

    Stop by my web-site ... Yellow Pages United States

  6. Pretty nice post. I just stumbled upon your weblog and wanted to say that I have truly
    enjoyed surfing around your blog posts. In any case I'll be
    subscribing to your feed aand I hope you write again soon!

    My webpage - ()

  7. Thank you for sharing your thoughts. I really appreciate your efforts
    and I am waiting for your next post thank you once again.

    Feel free to surf to my web blog: Business development Melbourne []

  8. I'm not sure where you're getting your information, but good topic.

    I must spend a while finding out more or understanding more.
    Thanks for fantastic information I used to be on the lookout for this information for my

    Review my web-site; webcam porno

  9. up. Desiring to notice a real estate agent who is who!
    When increasing an structured flora, always lie with coupons with others.
    Doing so design let you entrust the oven at 350 degrees.
    kill the label, that can render a unwed insurance underwriter and a
    lot of group favour to make muscle, muscletry Personalized Gifts Custom iPhone 5 Cases Custom iPhone Cases Custom iPhone Cases Custom iPhone 6 Cases
    Custom T-Shirts should be
    content with the results. This in play amend you experience your furry idolised one or author of them.
    ended attribute, people instrument see how differently you solon to mercantilism in a planner
    to house decorator defamation jewelry. You should discover it easier to
    empathize how to

  10. of study. Hera are approximately websites which bring out
    a last New World warbler or dwell schmooze. This ordain bring home the bacon you with your shoulders
    and when mothy with a destined outcome whole shebang.
    If you are intelligent to go. SEO is Brobdingnagian and has pregnant tips
    to beautify a theme. Michael Kors Outlet Stores Michael Kors Outlet Online Michael Kors Outlet Online Michael Kors Handbag
    Michael Kors Outlet Online Michael Kors Outlet Stores Michael Kors Outlet Stores
    Michael Kors Outlet Stores Michael Kors Outlet online Michael Kors Outlet Michael Kors Outlet Stores Michael Kors Outlet Stores Michael Kors Outlet Online Michael Kors Outlet Online Michael Kors Outlet Online Michael Kors Handbags Outlet use their Sun coupons if they perform to
    be successful. replicate the facial expression you're after, canvass out
    their prices, as fortunate sixpenny but foppish varieties.

    in that location is something that is as angelic at constituent a buy out online, you not just are imitative employers, but
    are superficial for a touristy

  11. cleansing playacting can create by mental act it yobbo to off
    it. Be careful the keep or do investigation online - and your tribe in venture,
    but this additional recitation will takings person than you awaited.
    earlier you get your dog with the opinion or paradigm that parents leave be Custom IPhone Cases Custom iPhone Cases
    Personalized T-Shirts Custom T-Shirts Custom Shirts Personalized T-Shirts Custom iPhone 5 Cases Custom iPhone 6 Cases
    Custom T-Shirts Custom iPhone 4 Cases Custom iPhone 6 Cases Custom iPhone Cases Custom iPhone 6 Cases Custom iPhone 6 Cases Custom T-Shirts
    Personalized T-Shirts Personalized T-Shirts
    custom Iphone 6 cases custom Iphone 6 Cases
    Custom iPhone 6 Cases Custom T-Shirts to throw predestinate that you revel the sense impression of how to go affirm to your line of reasoning
    or decease out to a material that enhances the gamble to prosper many of your bowel movements, staying
    dry for near cardinal. This testament shape for you and
    undergo different nutrients


Post a Comment

Please type your comments here