JAX-RS @GET RESTful webservice

In this tutorial we are going to see  about RESTful web service JAX-RS @GET annotation.

Ask your questions in eHowToNow Forum

Post your technical, non-technical doubts, questions in our site. Get answer as soon as possible, meanwhile you can help others by answering, unanswered questions.
To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

Create maven web application project and add Jersey dependency in pom.xml. Find Jersey 2.x maven dependency configuration below. If you are new to maven refer our maven tutorials .

Jersey 2.x dependency in pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <name>RestTutorials Maven Webapp</name>
      <!-- JAX-RS -->
        <!-- Jersey 2.19 -->


package com.ehowtonow.webservice;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

public class RESTfulGet {

 public Response getSite(@PathParam("site") String site) {
  return Response.status(200).entity("Web Site : " + site).build();


Configure Jersey 2.x Servlet dispatcher

 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

	<display-name>Restful Webservice Example</display-name>


Now you can run the service and access the service by calling the following URL


Ask your questions in eHowToNow Forum

To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

Posts You may Like

  1. Java 8 Sort Map by Key
  2. JAX-RS @MatrixParam Restful Webservice
  3. Java Tutorial – First Java Program
  4. JAX-RS @PATH for URI – Jersey
  5. How to Read File using BufferedReader
  6. Jackson Streaming API to Write JSON
  7. JAX-RS @PathParm Web service Example
  8. How to rotate element of List
  9. How to Read file using FileInputStream
  10. Java 8 Convert a Stream to List
  11. RESTful Web service to consume JSON and Produce XML – Jersey 1.x
  12. How to shuffle the element of collection (List)
  13. JSoup DOM methods
  14. JAX-RS Web service to Consume JSON using Jersey 1.x
  15. Java Data type and Identifier

Be the first to comment

Leave a Reply

Your email address will not be published.