0% found this document useful (0 votes)
31 views

Rest Jersey Example: Download Link: Https://jersey - Github.io/download - HTML

This document provides instructions for setting up a basic RESTful web service example using Jersey on Eclipse. It includes downloading the Jersey zip file, creating a dynamic web project in Eclipse, adding the Jersey jars to the lib folder, adding a basic web.xml configuration file, creating a provider class with a GET endpoint, and viewing the response by running the project on the server.

Uploaded by

Ashok Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Rest Jersey Example: Download Link: Https://jersey - Github.io/download - HTML

This document provides instructions for setting up a basic RESTful web service example using Jersey on Eclipse. It includes downloading the Jersey zip file, creating a dynamic web project in Eclipse, adding the Jersey jars to the lib folder, adding a basic web.xml configuration file, creating a provider class with a GET endpoint, and viewing the response by running the project on the server.

Uploaded by

Ashok Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ReST Notes [By Raghu Sir]. SathyaTechnologies,Ameerpet.

REST JERSEY EXAMPLE


Download Link: https://jersey.github.io/download.html

Type this URL in browser.

Scroll down to bottom (find for JAX-RS 1.1 / Jersey 1.x)

It will download .zip. Extract this:

Right click and extract here:

1
ReST Notes [By Raghu Sir]. SathyaTechnologies,Ameerpet.

Create Dynamic web Project in Eclipse: File=>new=>Dynamic Web Project.

=> Enter Project name => Click on Next button => finish

Copy All jars to lib folder.

2
ReST Notes [By Raghu Sir]. SathyaTechnologies,Ameerpet.

web.xml code:

<?xml version="1.0" encoding="UTF-8"?>


<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
<servlet>
<servlet-name>sample</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>sample</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>

Create one Provider class:

package com.app;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("/msg")
public class Message {

@Path("/show")
@GET
public String showMsg(){
return "hello";
}
}

=>right click on Project => Run As=> Run On Server=> URL


(http://localhost:2015/Provider/rest/msg/show)

3
ReST Notes [By Raghu Sir]. SathyaTechnologies,Ameerpet.

Folder Structure:

You might also like