Lab1 Instructions

User Manual: Pdf

Open the PDF directly: View PDF PDF.
Page Count: 7

DownloadLab1-instructions
Open PDF In BrowserView PDF
7. Assignment 1 - Hello
This assignment objectives are:
Validation of the setup of development environment
Run "Hello" from Eclipse in JETTY
Or
Build using maven and deploy in tomcat
Run "Hello" from tomcat

Work space
rest-lab1

Instructions
1. Web app maven project
2. Jersey config - pom.xml
a. Maven dependencies for Jersey, Servlet.
3. web.xml configuration
4. Hello from Jersery - HelloResource

Running
Running in Jetty or Tomcat
http://localhost:8080/lab1/rest/hello

Prerequisite :
You have JDK installed
and Eclipse Mars setup with JETTY plug-in

Instructions :
1. Create new project - File new -> project -> maven -> maven project

2. Press Next. It will show following screen. Skip this screen by pressing Next.

3. Select archtype as maven-archtype-webapp as below

4. Fill information as below in the next screen for the maven project and press Finish.

5. Add maven dependencies in pom.xml for jersey and servlet.


com.sun.jersey
jersey-server
1.19
compile



com.sun.jersey
jersey-servlet
1.19
compile

6. Add jersey servlet configuration in web.xml


Archetype Created Web Application

Jersey REST Service
com.sun.jersey.spi.container.servlet.ServletContainer

com.sun.jersey.config.property.packages
com.rest

1


Jersey REST Service
/rest/*


7. Select main -> new folder -> java - src/main/java
Then new package -> com.rest
You should see following:

8. New class HelloResource in com.rest package

package com.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("hello")
public class HelloResource {
@GET
@Produces(MediaType.TEXT_HTML)
public String sayHtmlHello() {
return "Hello from Jersey";
}
}
9. Select pom.xml and Run as JETTY



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.4
Linearized                      : No
Modify Date                     : 2016:01:31 07:39:24-08:00
Create Date                     : 2016:01:31 07:39:24-08:00
Producer                        : iText 2.1.7 by 1T3XT
Page Mode                       : UseOutlines
Page Count                      : 7
EXIF Metadata provided by EXIF.tools

Navigation menu